Skip to content

Commit

Permalink
doc: update NFS provisioner example
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Oct 12, 2020
1 parent 9c64f4b commit 03dc4d2
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 35 deletions.
2 changes: 2 additions & 0 deletions deploy/kubernetes/csi-nfs-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ spec:
labels:
app: csi-nfs-node
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: node-driver-registrar
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2
Expand Down
14 changes: 8 additions & 6 deletions examples/kubernetes/nfs-provisioner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/examples/kubernetes/nfs-provisioner/nfs-server.yaml
```

- After deploying, a new service `nfs-service` is created. The file share path is accessible at `10.0.171.239`. Verify if the NFS Server pod is running

```bash
$ kubectl get po nfs-server-pod
```
- After deploying, a new service `nfs-server` is created, nfs share path is`nfs-server.default.svc.cluster.local:/`.

- To check if the server is working, we can statically create a `PersistentVolume` and a `PersistentVolumeClaim`, and mount it onto a sample pod:

Expand All @@ -23,6 +19,12 @@ kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nf
Verify if the newly create deployment is Running:

```bash
$ kubectl get deploy nfs-busybox
# kubectl exec -it nfs-busybox-8cd8d9c5b-sf8mx sh
/ # df -h
Filesystem Size Used Available Use% Mounted on
...
nfs-server.default.svc.cluster.local:/
123.9G 15.2G 108.6G 12% /mnt
...
```

14 changes: 9 additions & 5 deletions examples/kubernetes/nfs-provisioner/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ spec:
mountOptions:
- hard
- nfsvers=4.1
nfs:
path: /
server: 10.0.171.239
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: /
---
kind: PersistentVolumeClaim
apiVersion: v1
Expand All @@ -25,7 +29,7 @@ spec:
- ReadWriteMany
resources:
requests:
storage: 2Gi
storage: 10Gi
volumeName: pv-nfs
storageClassName: ""
---
Expand Down Expand Up @@ -58,4 +62,4 @@ spec:
volumes:
- name: nfs
persistentVolumeClaim:
claimName: nfs
claimName: nfs
68 changes: 44 additions & 24 deletions examples/kubernetes/nfs-provisioner/nfs-server.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,59 @@
---
kind: Service
apiVersion: v1
metadata:
name: nfs-service
name: nfs-server
labels:
app: nfs-server
spec:
clusterIP: 10.0.171.239
type: ClusterIP # use "LoadBalancer" to get a public ip
selector:
role: nfs
app: nfs-server
ports:
- name: tcp-2049
port: 2049
protocol: TCP
- name: udp-111
port: 111
protocol: UDP

---
kind: Pod
apiVersion: v1
kind: Deployment
apiVersion: apps/v1
metadata:
name: nfs-server-pod
labels:
role: nfs
name: nfs-server
spec:
containers:
- name: nfs-server-container
image: itsthenetwork/nfs-server-alpine:latest
env:
- name: SHARED_DIRECTORY
value: "/exports"
volumeMounts:
- mountPath: /exports
name: nfs-vol
securityContext:
privileged: true
volumes:
- name: nfs-vol
emptyDir: {}
---
replicas: 1
selector:
matchLabels:
app: nfs-server
template:
metadata:
name: nfs-server
labels:
app: nfs-server
spec:
nodeSelector:
"kubernetes.io/os": linux
containers:
- name: nfs-server
image: itsthenetwork/nfs-server-alpine:latest
env:
- name: SHARED_DIRECTORY
value: "/exports"
volumeMounts:
- mountPath: /exports
name: nfs-vol
securityContext:
privileged: true
ports:
- name: tcp-2049
containerPort: 2049
protocol: TCP
- name: udp-111
containerPort: 111
protocol: UDP
volumes:
- name: nfs-vol
hostPath:
path: /nfs-vol # modify this to specify another path to store nfs share data
type: DirectoryOrCreate

0 comments on commit 03dc4d2

Please sign in to comment.