Container Storage Interface (CSI)
Container Storage Interface (CSI) is now available as Beta in Kubernetes v1.10. With the promotion to Beta, CSI is now enabled by default. For more information about CSI Beta implementation in Kubernetes, see Container Storage Interface (CSI) for Kubernetes Goes Beta .
Configuring CSI
Most CSI plug-ins require that the --allow-privileged=true flag is set on the API server binary and kubelet binaries. This flag is enabled by default in IBM Cloud Private. For an IBM Cloud Private environment, you can use CSI Volume
in a Kubernetes pod without having to set any extra configuration.
Example: Deploying a CSI NFS driver in IBM Cloud Private
Sample files used in this sample deployment are available from the Kubernetes GitHub repository. See kubernetes-csi/drivers .
- Install NFS. For more information about setting up NFS, see the Prerequisites section in the Creating an NFS PersistentVolume topic.
-
Clone the kubernetes-csi/drivers
repository.
-
Switch to the
nfsdirectory.cd drivers/pkg/nfs -
Create the deployment.
kubectl create -f ./deploy/kubernetes/The output resembles the following code:
service "csi-attacher-nfsplugin" created statefulset.apps "csi-attacher-nfsplugin" created serviceaccount "csi-attacher" created clusterrole.rbac.authorization.k8s.io "external-attacher-runner" created clusterrolebinding.rbac.authorization.k8s.io "csi-attacher-role" created daemonset.apps "csi-nodeplugin-nfsplugin" created serviceaccount "csi-nodeplugin" created clusterrole.rbac.authorization.k8s.io "csi-nodeplugin" created clusterrolebinding.rbac.authorization.k8s.io "csi-nodeplugin" created -
Deploy a pod by using the created CSI volume.
-
Locate the NFS server.
showmount -eThe output resembles the following code:
Export list for nfsserver: /nfs * -
Edit the
examples/kubernetes/nginx.yamlfile. Update theserverandshareparameters to match your system settings.cat examples/kubernetes/nginx.yaml | grep csi -A 5The output resembles the following code:
csi: driver: csi-nfsplugin volumeHandle: data-id volumeAttributes: server: 10.10.25.7 share: /nfs --- -
Create a pod using the NFS driver.
kubectl create -f examples/kubernetes/nginx.yamlThe output resembles the following code:
persistentvolume "data-nfsplugin" created persistentvolumeclaim "data-nfsplugin" created pod "nginx" created
-
-
Check the mount point.
-
Access the nginx container.
kubectl exec -it nginx sh -
Change to the
/var/wwwdirectory.cd /var/www -
Create a file.
touch test -
List the file on the mount point.
lsThe output resembles the following code:
test
-
-
Check the NFS server.
-
Find the server.
hostnameThe output resembles the following code:
nfsserver -
List the files on the server.
ls /nfsThe output resembles the following code:
test
-