Mount StorageAccount to AKS
参考链接:https://carlos.mendible.com/2019/04/16/aks-persistent-volume-with-existing-storage-account/ 最为重要的参考地址,按照这个配置加上namespace完全可以实现
具体步骤:
(1)storageaccount :azurestorageaccountname以及azurestorageaccountkey(可以从Connection String那里拿)
在这个账户下创建File share,如创建文件名为k8stest
(2)用到的yml:参考上面的链接去编写,记得根据自己项目的namespace在配置yml的时候也加上namespace。
(3)大概思路:
先新建StorageClass,需要改动的参数是storageAccount: 帐户名和location: 创建的共享文件夹的URL
再新建Secret,需要改动的参数是azureSstorageaccountname和azurestorageaccountkey,这两个是需要base64加密后的
再新建PV,引用刚才创建的storageClassName: 自己新建的StorageClass名 和 azureFile:secretName: 自己新建的secret名 shareName: 文件夹名
最后新建PVC,引用刚才创建的storageClassName: 自己新建的StorageClass名 和 volumeName: 自己新建的PV名
最后在Deployment里面引用PVC
(4)具体命令
kubectl apply -f /xxxxx.yml
就可以成功创建上述内容,可以用如下命令查看
kubectl get sc --namespace=xxx
kubectl get pv --namespace=xxx
kubectl get pvc --namespace=xxx
kubectl get secret --namespace=xxx
然后编写创建deployment的yml 执行就可以成功将PVC(私有卷声明)卷挂载到容器中的自己在mountpath上配的路径,成功之后就可以在azureSstorageaccount的共享文件夹里看到mountpath上配的路径的内容
pkubectl describe pod <pod-name> --namespace=xxx # 显示 Pod 的详细信息, 查看是否mount成功
更多基本知识参考
https://www.kubernetes.org.cn/pvpvcstorageclass
https://docs.azure.cn/zh-cn/aks/concepts-storage
https://kubernetes.io/docs/concepts/storage/persistent-volumes/
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#types-of-persistent-volumes
https://github.com/kubernetes/examples/tree/master/staging/volumes/azure_file
https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-linux
https://blog.csdn.net/weixin_43466725/article/details/87775961

浙公网安备 33010602011771号