...
| Code Block |
|---|
| language | bash |
|---|
| title | Deploy operator |
|---|
|
# Clone the repository and change directory
$ git clone --single-branch --branch v1.5.3 https://github.com/rook/rook.git
$ cd rook/cluster/examples/kubernetes/nfs
# Then launch
$ kubectl create -f common.yaml -f operator.yaml
# Check if the operator is up and running
$ kubectl get pod -n rook-nfs-system
NAME READY STATUS RESTARTS AGE
rook-nfs-operator-f79889845-8r5kq 1/1 Running 0 11m |
Create and Initialize NFS Server
Some preliminary steps
It is recommended that you create Pod Security Policies first. To do this, you can use the psp.yaml file already present in the folder with the usual command
| Code Block |
|---|
| language | bash |
|---|
| title | Pod Security Policies |
|---|
|
$ kubectl create -f psp.yaml
podsecuritypolicy.policy/rook-nfs-policy created
# To get it
$ kubectl get psp
NAME PRIV CAPS SELINUX RUNASUSER FSGROUP SUPGROUP READONLYROOTFS VOLUMES
rook-nfs-policy true DAC_READ_SEARCH,SYS_RESOURCE RunAsAny RunAsAny RunAsAny RunAsAny false configMap,downwardAPI,emptyDir,persistentVolumeClaim,secret,hostPath |
Before we create NFS Server we need to create ServiceAccount and RBAC rules
| Code Block |
|---|
| language | bash |
|---|
| title | ServiceAccount and RBAC |
|---|
|
$ kubectl create -f rbac.yaml
namespace/rook-nfs created
serviceaccount/rook-nfs-server created
clusterrole.rbac.authorization.k8s.io/rook-nfs-provisioner-runner created
clusterrolebinding.rbac.authorization.k8s.io/rook-nfs-provisioner-runner created |
NFS server
Now that the operator is running, we can create an instance of a NFS server by creating an instance of the nfsservers.nfs.rook.io resource. The various fields and options of the NFS server resource can be used to configure the server and its volumes to export.