doc: update NFS provisioner example

fix comments

fix comments
This commit is contained in:
andyzhangx 2020-10-12 14:02:18 +00:00
parent 9c64f4bc8a
commit 8a1b143ead
5 changed files with 78 additions and 50 deletions

View File

@ -14,6 +14,8 @@ spec:
labels: labels:
app: csi-nfs-node app: csi-nfs-node
spec: spec:
hostNetwork: true # original nfs connection would be broken without hostNetwork setting
dnsPolicy: ClusterFirstWithHostNet
containers: containers:
- name: node-driver-registrar - name: node-driver-registrar
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2 image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2

View File

@ -1,39 +0,0 @@
kind: Service
apiVersion: v1
metadata:
name: nfs-service
spec:
clusterIP: 10.0.171.239
selector:
role: nfs
ports:
- name: tcp-2049
port: 2049
protocol: TCP
- name: udp-111
port: 111
protocol: UDP
---
kind: Pod
apiVersion: v1
metadata:
name: nfs-server-pod
labels:
role: nfs
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: {}
---

View File

@ -8,11 +8,7 @@
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/examples/kubernetes/nfs-provisioner/nfs-server.yaml 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 - After deploying, a new service `nfs-server` is created, nfs share path is`nfs-server.default.svc.cluster.local:/`.
```bash
$ kubectl get po nfs-server-pod
```
- To check if the server is working, we can statically create a `PersistentVolume` and a `PersistentVolumeClaim`, and mount it onto a sample pod: - To check if the server is working, we can statically create a `PersistentVolume` and a `PersistentVolumeClaim`, and mount it onto a sample pod:
@ -23,6 +19,12 @@ kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nf
Verify if the newly create deployment is Running: Verify if the newly create deployment is Running:
```bash ```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
...
``` ```

View File

@ -12,9 +12,13 @@ spec:
mountOptions: mountOptions:
- hard - hard
- nfsvers=4.1 - nfsvers=4.1
nfs: csi:
path: / driver: nfs.csi.k8s.io
server: 10.0.171.239 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 kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
@ -25,7 +29,7 @@ spec:
- ReadWriteMany - ReadWriteMany
resources: resources:
requests: requests:
storage: 2Gi storage: 10Gi
volumeName: pv-nfs volumeName: pv-nfs
storageClassName: "" storageClassName: ""
--- ---
@ -58,4 +62,4 @@ spec:
volumes: volumes:
- name: nfs - name: nfs
persistentVolumeClaim: persistentVolumeClaim:
claimName: nfs claimName: nfs

View File

@ -0,0 +1,59 @@
---
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:
- name: tcp-2049
port: 2049
protocol: TCP
- name: udp-111
port: 111
protocol: UDP
---
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:
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