How to set up the SMB CSI driver in Kubernetes

Easy. Let's just do it.

Terminology

Server Message Block (SMB) - an application-layer network protocol for remote access to files, printers and other network resources. It is widely used in Windows networks.

Container Storage Interface (CSI) - a standard for exposing block and file storage to workloads (containers) in container orchestration systems such as Kubernetes. Although it can be used outside Kubernetes too, Kubernetes is all we care about here.

Requirements

Kubernetes 1.22+

Preparing the cluster nodes

  1. Linux nodes (Ubuntu). This one is simple - just install the cifs-utils package.
sudo apt install -y cifs-utils
  1. Windows nodes. We need to build csi-proxy.exe from source and install it. This is done on Linux. In theory you could do it on Windows as well, but I don't know my way around golang and I'm already in my pajamas.
git clone https://github.com/kubernetes-csi/csi-proxy
sudo make build

After a successful build you will find csi-proxy.exe in the /bin folder. Now it has to be installed as a service. Create the folders c:\etc\kubernetes\logs and c:\etc\kubernetes\node\bin and copy csi-proxy.exe into the latter. Then cast the spell:

$flags = "-windows-service -log_file=\etc\kubernetes\logs\csi-proxy.log -logtostderr=false"
sc.exe create csiproxy binPath= "\etc\kubernetes\node\bin\csi-proxy.exe $flags"
sc.exe failure csiproxy reset= 0 actions= restart/10000
sc.exe start csiproxy
  1. The cluster is ready for CSI drivers.

Installing the SMB CSI driver

Also simple:

curl -skSL https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/install-driver.sh | bash -s master --

Check that everything went well.

PS C:\Users\v.leschenko> kubectl -n kube-system get pod -o wide -l app=csi-smb-controller
NAME                                  READY   STATUS    RESTARTS   AGE    IP              NODE          NOMINATED NODE   READINESS GATES
csi-smb-controller-77897597b7-6vpgs   3/3     Running   0          3d3h   10.244.135.8    k8s-linux-3   <none>           <none>
csi-smb-controller-77897597b7-hkv9n   3/3     Running   0          3d3h   10.244.101.15   k8s-linux-2   <none>           <none>
PS C:\Users\v.leschenko> kubectl -n kube-system get pod -o wide -l app=csi-smb-node
NAME                 READY   STATUS    RESTARTS   AGE    IP               NODE          NOMINATED NODE   READINESS GATES
csi-smb-node-b4xjw   3/3     Running   0          3d3h   192.168.99.150   k8s-linux-1   <none>           <none>
csi-smb-node-bllsk   3/3     Running   0          3d3h   192.168.99.160   k8s-linux-2   <none>           <none>
csi-smb-node-k9m87   3/3     Running   0          3d3h   192.168.99.161   k8s-linux-3   <none>           <none>
PS C:\Users\v.leschenko> kubectl -n kube-system get pod -o wide -l app=csi-smb-node-win
NAME                     READY   STATUS    RESTARTS   AGE   IP              NODE            NOMINATED NODE   READINESS GATES
csi-smb-node-win-9k29c   3/3     Running   0          23h   10.244.147.27   k8s-windows-3   <none>           <none>
csi-smb-node-win-g64t2   3/3     Running   0          23h   10.244.159.35   k8s-windows-1   <none>           <none>
csi-smb-node-win-xl8b9   3/3     Running   0          23h   10.244.26.137   k8s-windows-2   <none>           <none>

How do you use all this?

That's another story. There will be a separate article later.

Useful links

  1. Kubernetes 1.22: CSI Windows Support (with CSI Proxy) reaches GA
  2. csi-proxy
  3. csi-driver-smb

Only registered users can leave a comment.

Sign in or register to leave a comment.