Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Use itsthenetwork/nfs-server-alpine for NFS server provisioning #59

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions examples/kubernetes/nfs-provisioner/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
# Set up a NFS Server on a Kubernetes cluster

> Note: This example is for development perspective only. Because the NFS server is sticky to the node it is scheduled on, data shall be lost if the pod is rescheduled on another node.
> Note: This example is for development only. Because the NFS server is sticky to the node it is scheduled on, data shall be lost if the pod is rescheduled on another node.

To create a NFS provisioner on your Kubernetes cluster, run the following command
- To create a NFS provisioner on your Kubernetes cluster, run the following command

```bash
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-server` is created. The file share path is accessible at `nfs-server.default.svc.cluster.local/nfsshare`.
- 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
```

To obtain a public IP for the service, run the following command instead
- To check if the server is working, we can statically create a `PersistentVolume` and a `PersistentVolumeClaim`, and mount it onto a sample pod:

```bash
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/examples/kubernetes/nfs-provisioner/nfs-server-lb.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/examples/kubernetes/nfs-provisioner/app.yaml
```

Verify if the newly create deployment is Running:

```bash
$ kubectl get deploy nfs-busybox
```

61 changes: 61 additions & 0 deletions examples/kubernetes/nfs-provisioner/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-nfs
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
mountOptions:
- hard
- nfsvers=4.1
nfs:
path: /
server: 10.0.171.239
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nfs
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 2Gi
volumeName: pv-nfs
storageClassName: ""
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-busybox
spec:
replicas: 1
selector:
matchLabels:
name: nfs-busybox
template:
metadata:
name: nfs-busybox
labels:
name: nfs-busybox
spec:
containers:
- image: busybox
command:
- sh
- -c
- 'while true; do date > /mnt/index.html; hostname >> /mnt/index.html; sleep $(($RANDOM % 5 + 5)); done'
imagePullPolicy: IfNotPresent
name: busybox
volumeMounts:
- name: nfs
mountPath: "/mnt"
volumes:
- name: nfs
persistentVolumeClaim:
claimName: nfs
43 changes: 0 additions & 43 deletions examples/kubernetes/nfs-provisioner/nfs-server-lb.yaml

This file was deleted.

64 changes: 30 additions & 34 deletions examples/kubernetes/nfs-provisioner/nfs-server.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
---
kind: Service
apiVersion: v1
metadata:
name: nfs-server
labels:
app: nfs-server
name: nfs-service
spec:
type: ClusterIP # use "LoadBalancer" to get a public ip
clusterIP: 10.0.171.239
selector:
app: nfs-server
role: nfs
ports:
- port: 2049
name: nfs-server
- name: tcp-2049
port: 2049
protocol: TCP
- name: udp-111
port: 111
protocol: UDP

---
kind: Deployment
apiVersion: apps/v1
kind: Pod
apiVersion: v1
metadata:
name: nfs-server
name: nfs-server-pod
labels:
role: nfs
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:
path: /exports
type: DirectoryOrCreate
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: {}
---
20 changes: 0 additions & 20 deletions examples/kubernetes/nfs-provisioner/pv-nfs-csi.yaml

This file was deleted.