2015-07-14 00:13:09 +00:00
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
<!-- BEGIN STRIP_FOR_RELEASE -->
2015-07-16 17:02:26 +00:00
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< img src = "http://kubernetes.io/img/warning.png" alt = "WARNING"
width="25" height="25">
< h2 > PLEASE NOTE: This document applies to the HEAD of the source tree< / h2 >
If you are using a released version of Kubernetes, you should
refer to the docs that go with that version.
< strong >
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 ](http://releases.k8s.io ).
< / strong >
--
2015-07-13 22:15:35 +00:00
2015-07-14 00:13:09 +00:00
<!-- END STRIP_FOR_RELEASE -->
<!-- END MUNGE: UNVERSIONED_WARNING -->
2015-07-17 22:35:41 +00:00
2015-04-02 08:47:21 +00:00
# Example of NFS volume
See [nfs-web-pod.yaml ](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 import it
into another one.
2015-07-17 22:35:41 +00:00
### Prerequisites
2015-06-11 17:33:29 +00:00
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.
2015-07-20 16:40:32 +00:00
```sh
2015-06-11 17:33:29 +00:00
#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
```
2015-09-06 10:28:18 +00:00
For other non-salt based provider, you can set `--allow-privileged=true` for both api-server and kubelet, and then restart these components.
2015-06-11 17:33:29 +00:00
Rebuild the Kubernetes and spin up a cluster using your preferred KUBERNETES_PROVIDER.
2015-04-02 08:47:21 +00:00
### NFS server part
Define [NFS server pod ](nfs-server-pod.yaml ) and
[NFS service ](nfs-server-service.yaml ):
$ 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 ](nfs-web-pod.yaml ) 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!
2015-05-14 22:12:45 +00:00
2015-07-14 00:13:09 +00:00
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
2015-05-14 22:12:45 +00:00
[![Analytics ](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/nfs/README.md?pixel )]()
2015-07-14 00:13:09 +00:00
<!-- END MUNGE: GENERATED_ANALYTICS -->