text stringlengths 0 59.1k |
|---|
template: |
metadata: |
labels: |
role: nfs-server |
spec: |
containers: |
- name: nfs-server |
image: registry.k8s.io/volume-nfs:0.8 |
ports: |
- name: nfs |
containerPort: 2049 |
- name: mountd |
containerPort: 20048 |
- name: rpcbind |
containerPort: 111 |
securityContext: |
privileged: true |
volumeMounts: |
- mountPath: /exports |
name: mypvc |
volumes: |
- name: mypvc |
persistentVolumeClaim: |
claimName: nfs-pv-provisioning-demo |
<|endoftext|> |
# source: k8s_examples/_archived/volumes/nfs/README.md type: docs |
# Outline |
This example describes how to create Web frontend server, an auto-provisioned persistent volume on GCE or Azure, and an NFS-backed persistent claim. |
Demonstrated Kubernetes Concepts: |
* [Persistent Volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) to |
define persistent disks (disk lifecycle not tied to the Pods). |
* [Services](https://kubernetes.io/docs/concepts/services-networking/service/) to enable Pods to |
locate one another. |
![alt text][nfs pv example] |
As illustrated above, two persistent volumes are used in this example: |
- Web frontend Pod uses a persistent volume based on NFS server, and |
- NFS server uses an auto provisioned [persistent volume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) from GCE PD or AWS EBS or Azure Disk. |
Note, this example uses an NFS container that doesn't support NFSv4. |
[nfs pv example]: nfs-pv.png |
## Quickstart |
```console |
# On GCE (create GCE PD PVC): |
$ kubectl create -f examples/staging/volumes/nfs/provisioner/nfs-server-gce-pv.yaml |
# On Azure (create Azure Disk PVC): |
$ kubectl create -f examples/staging/volumes/nfs/provisioner/nfs-server-azure-pv.yaml |
# Common steps after creating either GCE PD or Azure Disk PVC: |
$ kubectl create -f examples/staging/volumes/nfs/nfs-server-deployment.yaml |
$ kubectl create -f examples/staging/volumes/nfs/nfs-server-service.yaml |
# get the cluster IP of the server using the following command |
$ kubectl describe services nfs-server |
# use the NFS server IP to update nfs-pv.yaml and execute the following |
$ kubectl create -f examples/staging/volumes/nfs/nfs-pv.yaml |
$ kubectl create -f examples/staging/volumes/nfs/nfs-pvc.yaml |
# run a fake backend |
$ kubectl create -f examples/staging/volumes/nfs/nfs-busybox-deployment.yaml |
# get pod name from this command |
$ kubectl get pod -l name=nfs-busybox |
# use the pod name to check the test file |
$ kubectl exec nfs-busybox-jdhf3 -- cat /mnt/index.html |
``` |
## Example of NFS based persistent volume |
See [NFS Service and Deployment](nfs-web-deployment.yaml) for a quick example of how to use an NFS |
volume claim in a deployment. It relies on the |
[NFS persistent volume](nfs-pv.yaml) and |
[NFS persistent volume claim](nfs-pvc.yaml) in this example as well. |
## Complete setup |
The example below shows how to export a NFS share from a single pod |
deployment and import it into two deployments. |
### NFS server part |
Define [the NFS Service and Deployment](nfs-server-deployment.yaml) and |
[NFS service](nfs-server-service.yaml): |
The NFS server exports an auto-provisioned persistent volume backed by GCE PD or Azure Disk. If you are on GCE, create a GCE PD-based PVC: |
```console |
$ kubectl create -f examples/staging/volumes/nfs/provisioner/nfs-server-gce-pv.yaml |
``` |
If you are on Azure, create an Azure Premium Disk-based PVC: |
```console |
$ kubectl create -f examples/staging/volumes/nfs/provisioner/nfs-server-azure-pv.yaml |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.