Skip to content

Instantly share code, notes, and snippets.

@johnsimcall
Last active November 8, 2023 07:39
Show Gist options
  • Save johnsimcall/0428b7768e50ece76d63db5ec2ab39b5 to your computer and use it in GitHub Desktop.
Save johnsimcall/0428b7768e50ece76d63db5ec2ab39b5 to your computer and use it in GitHub Desktop.
Simplified NFS storage for OpenShift
cd ~/ocp/
git clone https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner.git
cd nfs-subdir-external-provisioner
sed -i.backup 's/nfs-client/nfs-storage/g' ./deploy/class.yaml
sed -i.backup 's/namespace:.*/namespace: nfs-storage/g' ./deploy/rbac.yaml
sed -i.backup 's/namespace:.*/namespace: nfs-storage/g' ./deploy/deployment.yaml
vi ./deploy/deployment.yaml
#Update NFS_SERVER and NFS_PATH values (4 edits required)
diff -U0 ./deploy/class.yaml{.backup,}
diff -U0 ./deploy/rbac.yaml{.backup,}
diff -U0 ./deploy/deployment.yaml{.backup,}
oc new-project nfs-storage
oc create -f ./deploy/rbac.yaml
oc adm policy add-scc-to-user hostmount-anyuid system:serviceaccount:nfs-storage:nfs-client-provisioner
oc create -f ./deploy/deployment.yaml
oc create -f ./deploy/class.yaml
oc annotate storageclass/nfs-storage storageclass.kubernetes.io/is-default-class=true
@johnsimcall
Copy link
Author

johnsimcall commented Dec 3, 2021

This assumes that you've already got a working NFS server and oc or kubectl working with cluster-admin permissions. If not, here are steps to turn a RHEL8 box into an NFS server.

@johnsimcall
Copy link
Author

Dec 21, 2021 - Change StorageClass name from managed-nfs-storage to just nfs-storage. Use an oc patch ... command to set the new StorageClass as default instead of manually adding two or three lines into the YAML manifest.

@johnsimcall
Copy link
Author

johnsimcall commented May 10, 2022

A recent update to the upstream Git repo changed the StorageClass name (in deploy/class.yaml) to nfs-client

I'm going to start looking at this NFS storage provisioner[1] alternative that promises to provide CSI capabilities (like snapshots.)
[1] - https://github.com/kubernetes-csi/csi-driver-nfs

UPDATE: I'm not entirely impressed with the securityContextConstraints, but I got it to work... Here are my notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment