...
Update the NFS server security group to allow TCP port 2049.
Step 8: Apply NFS-Common Library on Rancher Worker Nodes
Install the NFS Common Library on Rancher Worker Nodes to enable nfs utilities on worker nodes as well.
| Code Block |
|---|
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: install-nfs-common
namespace: kube-system
spec:
selector:
matchLabels:
app: install-nfs-common
template:
metadata:
labels:
app: install-nfs-common
spec:
hostPID: true
hostNetwork: true
containers:
- name: install
image: busybox:latest
command: ["/bin/sh", "-c"]
args:
- nsenter --mount=/proc/1/ns/mnt -- /bin/sh -c 'apt update && apt install -y nfs-common' && sleep infinity
securityContext:
privileged: true
restartPolicy: Always |
This DaemonSet will ensures to install nfs common library on all kubernetes worker nodes and this will only work on ubuntu worker nodes.
Step 9: Apply NFS Manifest
Apply the NFS manifest to your Rancher cluster, while applying the manifest, don’t forget to update with the private IP of your NFS sever , at the last section of the manifest
...
| Code Block |
|---|
apiVersion: v1
kind: Namespace
metadata:
name: nfs
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-client-provisioner
namespace: nfs
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-client-provisioner-runner
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "update", "patch"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: run-nfs-client-provisioner
subjects:
- kind: ServiceAccount
name: nfs-client-provisioner
namespace: nfs
roleRef:
kind: ClusterRole
name: nfs-client-provisioner-runner
apiGroup: rbac.authorization.k8s.io
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: nfs
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: nfs-test
parameters:
archiveOnDelete: "false"
reclaimPolicy: Delete
volumeBindingMode: Immediate
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-client-provisioner
namespace: nfs
spec:
replicas: 1
selector:
matchLabels:
app: nfs-client-provisioner
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-client-provisioner
spec:
serviceAccountName: nfs-client-provisioner
containers:
- name: nfs-client-provisioner
image: k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: nfs-test
- name: NFS_SERVER
value: 10.0.14.162 # Replace with your NFS server IP
- name: NFS_PATH
value: /nfs-share # Replace with your NFS share path
volumes:
- name: nfs-client-root
nfs:
server: 10.0.14.162 # Replace with your NFS server IP
path: /nfs-share # Replace with your NFS share path |
Step
...
Install the NFS Common Library on Rancher Worker Nodes to enable nfs utilities on worker nodes as well.
| Code Block |
|---|
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: install-nfs-common
namespace: kube-system
spec:
selector:
matchLabels:
app: install-nfs-common
template:
metadata:
labels:
app: install-nfs-common
spec:
hostPID: true
hostNetwork: true
containers:
- name: install
image: busybox:latest
command: ["/bin/sh", "-c"]
args:
- nsenter --mount=/proc/1/ns/mnt -- /bin/sh -c 'apt update && apt install -y nfs-common' && sleep infinity
securityContext:
privileged: true
restartPolicy: Always |
...
10: Check for the nfs storage class creation
| Code Block |
|---|
kubectl get storageclass |
...
This document provides a comprehensive guide for deploying and configuring an NFS server on Rancher, ensuring proper integration for seamless operation.
...