Skip to content

Commit 0b20e81

Browse files
authored
Merge pull request #61 from andyzhangx/nfs-example
doc: update NFS provisioner example
2 parents ce37a10 + 8a1b143 commit 0b20e81

File tree

5 files changed

+78
-50
lines changed

5 files changed

+78
-50
lines changed

deploy/kubernetes/csi-nfs-node.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ spec:
1414
labels:
1515
app: csi-nfs-node
1616
spec:
17+
hostNetwork: true # original nfs connection would be broken without hostNetwork setting
18+
dnsPolicy: ClusterFirstWithHostNet
1719
containers:
1820
- name: node-driver-registrar
1921
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2

examples/kubernetes/nfs-provisioner/nfs-server.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.

examples/kubernetes/nfs-provisioner/README.md renamed to examples/kubernetes/nfs-server/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/examples/kubernetes/nfs-provisioner/nfs-server.yaml
99
```
1010

11-
- 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
12-
13-
```bash
14-
$ kubectl get po nfs-server-pod
15-
```
11+
- After deploying, a new service `nfs-server` is created, nfs share path is`nfs-server.default.svc.cluster.local:/`.
1612

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

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

2521
```bash
26-
$ kubectl get deploy nfs-busybox
22+
# kubectl exec -it nfs-busybox-8cd8d9c5b-sf8mx sh
23+
/ # df -h
24+
Filesystem Size Used Available Use% Mounted on
25+
...
26+
nfs-server.default.svc.cluster.local:/
27+
123.9G 15.2G 108.6G 12% /mnt
28+
...
2729
```
2830

examples/kubernetes/nfs-provisioner/app.yaml renamed to examples/kubernetes/nfs-server/deployment.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ spec:
1212
mountOptions:
1313
- hard
1414
- nfsvers=4.1
15-
nfs:
16-
path: /
17-
server: 10.0.171.239
15+
csi:
16+
driver: nfs.csi.k8s.io
17+
readOnly: false
18+
volumeHandle: unique-volumeid # make sure it's a unique id in the cluster
19+
volumeAttributes:
20+
server: nfs-server.default.svc.cluster.local
21+
share: /
1822
---
1923
kind: PersistentVolumeClaim
2024
apiVersion: v1
@@ -25,7 +29,7 @@ spec:
2529
- ReadWriteMany
2630
resources:
2731
requests:
28-
storage: 2Gi
32+
storage: 10Gi
2933
volumeName: pv-nfs
3034
storageClassName: ""
3135
---
@@ -58,4 +62,4 @@ spec:
5862
volumes:
5963
- name: nfs
6064
persistentVolumeClaim:
61-
claimName: nfs
65+
claimName: nfs
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
kind: Service
3+
apiVersion: v1
4+
metadata:
5+
name: nfs-server
6+
labels:
7+
app: nfs-server
8+
spec:
9+
type: ClusterIP # use "LoadBalancer" to get a public ip
10+
selector:
11+
app: nfs-server
12+
ports:
13+
- name: tcp-2049
14+
port: 2049
15+
protocol: TCP
16+
- name: udp-111
17+
port: 111
18+
protocol: UDP
19+
---
20+
kind: Deployment
21+
apiVersion: apps/v1
22+
metadata:
23+
name: nfs-server
24+
spec:
25+
replicas: 1
26+
selector:
27+
matchLabels:
28+
app: nfs-server
29+
template:
30+
metadata:
31+
name: nfs-server
32+
labels:
33+
app: nfs-server
34+
spec:
35+
nodeSelector:
36+
"kubernetes.io/os": linux
37+
containers:
38+
- name: nfs-server
39+
image: itsthenetwork/nfs-server-alpine:latest
40+
env:
41+
- name: SHARED_DIRECTORY
42+
value: "/exports"
43+
volumeMounts:
44+
- mountPath: /exports
45+
name: nfs-vol
46+
securityContext:
47+
privileged: true
48+
ports:
49+
- name: tcp-2049
50+
containerPort: 2049
51+
protocol: TCP
52+
- name: udp-111
53+
containerPort: 111
54+
protocol: UDP
55+
volumes:
56+
- name: nfs-vol
57+
hostPath:
58+
path: /nfs-vol # modify this to specify another path to store nfs share data
59+
type: DirectoryOrCreate

0 commit comments

Comments
 (0)