k3s/examples/nfs
feihujiang 310f8f6320 Fix minor errors in nfs example 2015-10-21 15:15:03 +08:00
..
exporter Run gendocs 2015-07-17 15:35:43 -07:00
nfs-data Run gendocs 2015-07-17 15:35:43 -07:00
README.md Fix minor errors in nfs example 2015-10-21 15:15:03 +08:00
nfs-server-pod.yaml update example/nfs to v1 2015-06-10 16:04:53 -07:00
nfs-server-service.yaml update example/nfs to v1 2015-06-10 16:04:53 -07:00
nfs-web-pod.yaml nfs example: Fix document root in comment 2015-06-12 14:03:23 -04:00

README.md

WARNING WARNING WARNING WARNING WARNING

PLEASE NOTE: This document applies to the HEAD of the source tree

If you are using a released version of Kubernetes, you should refer to the docs that go with that version.

The latest 1.0.x release of this document can be found [here](http://releases.k8s.io/release-1.0/examples/nfs/README.md).

Documentation for other releases can be found at releases.k8s.io.

Example of NFS volume

See nfs-web-pod.yaml for a quick example, how to use NFS volume in a pod.

Complete setup

The example below shows how to export a NFS share from a pod and imports it into another one.

Prerequisites

The nfs server pod creates a privileged container, so if you are using a Salt based KUBERNETES_PROVIDER (gce, vagrant, aws), you have to enable the ability to create privileged containers by API.

# At the root of Kubernetes source code
$ vi cluster/saltbase/pillar/privilege.sls

# If true, allow privileged containers to be created by API
allow_privileged: true

For other non-salt based provider, you can set --allow-privileged=true for both api-server and kubelet, and then restart these components.

Rebuild the Kubernetes and spin up a cluster using your preferred KUBERNETES_PROVIDER.

NFS server part

Define NFS server pod and NFS service:

$ kubectl create -f nfs-server-pod.yaml
$ kubectl create -f nfs-server-service.yaml

The server exports /mnt/data directory as / (fsid=0). The directory contains dummy index.html. Wait until the pod is running!

NFS client

WEB server pod uses the NFS share exported above as a NFS volume and runs simple web server on it. The pod assumes your DNS is configured and the NFS service is reachable as nfs-server.default.kube.local. Edit the yaml file to supply another name or directly its IP address (use kubectl get services to get it).

Define the pod:

$ kubectl create -f nfs-web-pod.yaml

Now the pod serves index.html from the NFS server:

$ curl http://<the container IP address>/
Hello World!

Analytics