From 22bb5db3126a9d3160b41846c6fb2507931f4512 Mon Sep 17 00:00:00 2001 From: Mayank Shah Date: Thu, 8 Oct 2020 18:21:15 +0530 Subject: [PATCH] Add example for NFS server Signed-off-by: Mayank Shah --- examples/kubernetes/nfs-provisioner/README.md | 15 +++++++ .../nfs-provisioner/nfs-server-lb.yaml | 42 +++++++++++++++++++ .../nfs-provisioner/nfs-server.yaml | 42 +++++++++++++++++++ .../nfs-provisioner/pv-nfs-csi.yaml | 20 +++++++++ 4 files changed, 119 insertions(+) create mode 100644 examples/kubernetes/nfs-provisioner/README.md create mode 100644 examples/kubernetes/nfs-provisioner/nfs-server-lb.yaml create mode 100644 examples/kubernetes/nfs-provisioner/nfs-server.yaml create mode 100644 examples/kubernetes/nfs-provisioner/pv-nfs-csi.yaml diff --git a/examples/kubernetes/nfs-provisioner/README.md b/examples/kubernetes/nfs-provisioner/README.md new file mode 100644 index 000000000..0b749e5f4 --- /dev/null +++ b/examples/kubernetes/nfs-provisioner/README.md @@ -0,0 +1,15 @@ +# Set up a NFS Server on a Kubernetes cluster + +To create a NFS provisioner on your Kubernetes cluster, run the following command + +```bash +kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/nfs-driver-smb/master/examples/kubernetes/nfs-provisioner/nfs-server.yaml +``` + +After deploying, a new service `nfs-server` is created. The file share path is accessible at `nfs-server.default.svc.cluster.local/nfsshare`. + +To obtain a public IP for the service, run the following command instead + +```bash +kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/nfs-driver-smb/master/examples/kubernetes/nfs-provisioner/nfs-server-lb.yaml +``` \ No newline at end of file diff --git a/examples/kubernetes/nfs-provisioner/nfs-server-lb.yaml b/examples/kubernetes/nfs-provisioner/nfs-server-lb.yaml new file mode 100644 index 000000000..4ccd14f04 --- /dev/null +++ b/examples/kubernetes/nfs-provisioner/nfs-server-lb.yaml @@ -0,0 +1,42 @@ +--- +kind: Service +apiVersion: v1 +metadata: + name: nfs-server + labels: + app: nfs-server +spec: + type: LoadBalancer + selector: + app: nfs-server + ports: + - port: 2049 + name: nfs-server +--- +kind: Deployment +apiVersion: apps/v1 +metadata: + name: nfs-server +spec: + replicas: 1 + selector: + matchLabels: + app: nfs-server + template: + metadata: + name: nfs-server + labels: + app: nfs-server + spec: + containers: + - name: nfs-server + image: gcr.io/kubernetes-e2e-test-images/volume/nfs:1.0 + ports: + - containerPort: 2049 + volumeMounts: + - mountPath: /nfsshare + name: data-volume + volumes: + name: data-volume + hostPath: /nfsshare-volume + type: DirectoryOrCreate \ No newline at end of file diff --git a/examples/kubernetes/nfs-provisioner/nfs-server.yaml b/examples/kubernetes/nfs-provisioner/nfs-server.yaml new file mode 100644 index 000000000..8ed8dbc4d --- /dev/null +++ b/examples/kubernetes/nfs-provisioner/nfs-server.yaml @@ -0,0 +1,42 @@ +--- +kind: Service +apiVersion: v1 +metadata: + name: nfs-server + labels: + app: nfs-server +spec: + type: ClusterIP # use "LoadBalancer" to get a public ip + selector: + app: nfs-server + ports: + - port: 2049 + name: nfs-server +--- +kind: Deployment +apiVersion: apps/v1 +metadata: + name: nfs-server +spec: + replicas: 1 + selector: + matchLabels: + app: nfs-server + template: + metadata: + name: nfs-server + labels: + app: nfs-server + spec: + containers: + - name: nfs-server + image: gcr.io/kubernetes-e2e-test-images/volume/nfs:1.0 + ports: + - containerPort: 2049 + volumeMounts: + - mountPath: /nfsshare + name: data-volume + volumes: + name: data-volume + hostPath: /nfsshare-volume + type: DirectoryOrCreate \ No newline at end of file diff --git a/examples/kubernetes/nfs-provisioner/pv-nfs-csi.yaml b/examples/kubernetes/nfs-provisioner/pv-nfs-csi.yaml new file mode 100644 index 000000000..e3c0261db --- /dev/null +++ b/examples/kubernetes/nfs-provisioner/pv-nfs-csi.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pv-nfs +spec: + capacity: + storage: 1Gi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + mountOptions: + - vers=3.0 + csi: + driver: nfs.csi.k8s.io + readOnly: false + volumeHandle: unique-volumeid # make sure it's a unique id in the cluster + volumeAttributes: + server: nfs-server.default.svc.cluster.local + share: /nfsshare \ No newline at end of file