WARNING: This driver is in maintenance mode. Please use SMB CSI driver instead.
- supported Kubernetes version: available from v1.7
- supported agent OS: Linux
For Windows support, refer to https://github.com/Microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows
This driver allows Kubernetes to access SMB server by using CIFS/SMB protocol.
mcr.microsoft.com/k8s/flexvolume/smb-flexvolume:1.0.5
See ./helm/README.md for instructions on deploying an SMB share to your Kubernetes cluster using Helm.
The Helm chart compresses the steps below, including installing jq and cifs-utils on each cluster node,
into one config file (./helm/smb-flexvol/values.yaml) and one deployment step.
Make sure jq, cifs-utils packages have already been installed on every agent node of Kubernetes cluster
these packages have already been installed in Kubernetes cluster created by AKS or aks-engine.
Note: skip this step in AKS and aks-engine
Please refer to config kubelet service to enable FlexVolume driver
Note: You may replace
/etc/kubernetes/volumepluginswith/usr/libexec/kubernetes/kubelet-plugins/volume/exec/(by default) ininstall-smb-flexvol-ubuntu.shif it's not a Kubernetes cluster created by AKS or aks-engine
create daemonset to install smb driver
kubectl apply -f https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/deployment/smb-flexvol-installer.yaml
- check daemonset status:
watch kubectl describe daemonset smb-flexvol-installer --namespace=kube-system
watch kubectl get po --namespace=kube-system -o wide
Note: for deployment on v1.7, it requires restarting kubelet on every node(
sudo systemctl restart kubelet) after daemonset running complete due to Dynamic Plugin Discovery not supported on k8s v1.7
- run following command on every agent node
Note: below script only applies to Ubuntu
curl -skSL https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/deployment/install-smb-flexvol-ubuntu.sh | sh -s --
kubectl create secret generic smbcreds --from-literal username=USERNAME --from-literal password="PASSWORD" --type="microsoft.com/smb"
append
\before special characters(e.g.$!), ifechocommand works well, then password could be parsed in smb plugin, follow details here
- download
nginx-flex-smb.yamlfile and modifysourcefield
wget -O nginx-flex-smb.yaml https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/nginx-flex-smb.yaml
vi nginx-flex-smb.yaml
- create a pod with smb flexvolume driver mount
kubectl create -f nginx-flex-smb.yaml
Note: access modes of smb PV supports ReadWriteOnce(RWO), ReadOnlyMany(ROX) and ReadWriteMany(RWX)
- download
pv-smb-flexvol.yamlfile, modifysourcefield and create a smb flexvolume persistent volume(PV)
wget https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/pv-smb-flexvol.yaml
vi pv-smb-flexvol.yaml
kubectl create -f pv-smb-flexvol.yaml
- create a smb flexvolume persistent volume claim(PVC)
kubectl create -f https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/pvc-smb-flexvol.yaml
- check status of PV & PVC until its Status changed from
PendingtoBound
kubectl get pv
kubectl get pvc
- create a pod with smb flexvolume PVC
kubectl create -f https://raw.githubusercontent.com/Azure/kubernetes-volume-drivers/master/flexvolume/smb/nginx-flex-smb-pvc.yaml
- watch the status of pod until its Status changed from
PendingtoRunning
watch kubectl describe po nginx-flex-smb
- enter the pod container
kubectl exec -it nginx-flex-smb -- bash
root@nginx-flex-smb:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 291G 3.2G 288G 2% /
tmpfs 3.4G 0 3.4G 0% /dev
tmpfs 3.4G 0 3.4G 0% /sys/fs/cgroup
//xiazhang3.file.core.windows.net/k8stest 25G 64K 25G 1% /data
/dev/sda1 291G 3.2G 288G 2% /etc/hosts
shm 64M 0 64M 0% /dev/shm
tmpfs 3.4G 12K 3.4G 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 3.4G 0 3.4G 0% /sys/firmware
In the above example, there is a /data directory mounted as smb filesystem.
| Name | Meaning | Example | Mandatory |
|---|---|---|---|
| source | smb server address | //STORAGE-ACCOUNT.file.core.windows.net/SHARE-NAME for auzre file format |
Yes |
| mountoptions | mount options | vers=3.0,dir_mode=0777,file_mode=0777 |
No |
- Check smb flexvolume installation result on the node:
sudo cat /var/log/smb-flexvol-installer.log
- Get smb driver version:
kubectl get po -n kube-system | grep smb
kubectl describe po smb-flexvol-installer-xxxxx -n kube-system | grep smb-flexvolume
- If there is pod mounting error like following:
MountVolume.SetUp failed for volume "test" : invalid character 'C' looking for beginning of value
Please attach log file /var/log/smb-driver.log and file an issue
Skaffold can make it easier to iteratively debug the helm chart / docker installer. See ./skaffold.yaml for details.