available from v1.7.0
Option#1: find a suitable storage account that matches skuName
in same resource group when provisioning azure file
kubectl create -f https://raw.githubusercontent.com/andyzhangx/Demo/master/pv/storageclass-azurefile.yaml
- download
storageclass-azurefile-account.yaml
file and modifystorageAccount
values
wget https://raw.githubusercontent.com/andyzhangx/Demo/master/pv/storageclass-azurefile-account.yaml
vi storageclass-azurefile-account.yaml
kubectl create -f storageclass-azurefile-account.yaml
Note: make sure the specified storage account is in the same resource group as your k8s cluster
kubectl create -f https://raw.githubusercontent.com/andyzhangx/Demo/master/pv/pvc-azurefile.yaml
watch kubectl describe pvc pvc-azurefile
kubectl create -f https://raw.githubusercontent.com/andyzhangx/Demo/master/linux/azurefile/nginx-pod-azurefile.yaml
watch kubectl describe po nginx-azurefile
kubectl exec -it nginx-azurefile -- bash
root@nginx-azurefile:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 30G 3.6G 26G 13% /
tmpfs 6.9G 0 6.9G 0% /dev
tmpfs 6.9G 0 6.9G 0% /sys/fs/cgroup
/dev/sda1 30G 3.6G 26G 13% /etc/hosts
//f5713de20cde511e8ba4900.file.core.windows.net/xxx 4.8G 12M 4.6G 1% /mnt/azurefile
shm 64M 0 64M 0% /dev/shm
tmpfs 6.9G 12K 6.9G 1% /run/secrets/kubernetes.io/serviceaccount
- To specify a storage account in azure file dynamic provision, you should make sure the specified storage account is in the same resource group as your k8s cluster. In AKS, the specified storage account should be in a
shadow resource group
(naming asMC_+{RESOUCE-GROUP-NAME}+{CLUSTER-NAME}+{REGION}
) which contains all resources of your aks cluster.
- available from v1.5.0
- static provisioning: user must create an azure file before using azure file mount feature.
- kubernetes v1.5, v1.6 does not support azure file dynamic provisioning, only static provisioning is available
- create an azure file share in Azure storage account in the same resource group with k8s cluster
- get
azurestorageaccountname
,azurestorageaccountkey
andshareName
of that azure file
kubectl create secret generic azure-secret --from-literal azurestorageaccountname=NAME --from-literal azurestorageaccountkey="KEY" --type=Opaque
Option#2: create a azure-secrect.yaml
file that contains base64 encoded Azure Storage account name and key
-
base64-encode azurestorageaccountname and azurestorageaccountkey. You could leverage this site
-
download
azure-secrect.yaml
file and modifyazurestorageaccountname
,azurestorageaccountkey
base64-encoded values
wget https://raw.githubusercontent.com/andyzhangx/Demo/master/pv/azure-secrect.yaml
vi azure-secrect.yaml
- create
azure-secrect
for azure file
kubectl create -f azure-secrect.yaml
download nginx-pod-azurefile-static.yaml
file and modify shareName
value
wget https://raw.githubusercontent.com/andyzhangx/Demo/master/linux/azurefile/nginx-pod-azurefile-static.yaml
vi nginx-pod-azurefile-static.yaml
kubectl create -f nginx-pod-azurefile-static.yaml
watch kubectl describe po nginx-azurefile
kubectl exec -it nginx-azurefile -- bash
root@nginx-azurefile:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 30G 3.6G 26G 13% /
tmpfs 6.9G 0 6.9G 0% /dev
tmpfs 6.9G 0 6.9G 0% /sys/fs/cgroup
/dev/sda1 30G 3.6G 26G 13% /etc/hosts
/dev/sdc 4.8G 12M 4.6G 1% /mnt/azurefile
shm 64M 0 64M 0% /dev/shm
tmpfs 6.9G 12K 6.9G 1% /run/secrets/kubernetes.io/serviceaccount
root@nginx-azurefile:/# mount | grep cifs
//pvc3329812692002.file.core.windows.net/andy-mgwin1710-dynamic-pvc-7b5346be-d577-11e7-bc95-000d3a041274 on /mnt/azurefile type cifs (rw,relatime,vers=3.0,cache=strict,username=pvc3329812692002,domain=,uid=0,noforceuid,gid=0,noforcegid,addr=52.239.184.8,file_mode=0777,dir_mode=0777,persistenthandles,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)
Premium_LRS
storage type is supported from k8s v1.13.0- other azure file plugin known issues
//ACCOUNT-NAME.file.core.windows.net/sharename on /var/lib/kubelet/pods/dd141c4f-501c-11e8-8c6d-0a58ac1f078e/volumes/kubernetes.io~azure-file/azure type cifs (rw,relatime,vers=3.0,cache=strict,username=ACCOUNT-NAME,domain=,uid=0,noforceuid,gid=0,noforcegid,addr=52.239.152.8,file_mode=0755,dir_mode=0755,persistenthandles,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)