管理类手机网站,wordpress 文章表格,网站干什么的,国内用python做的网站本文作者|搪瓷小娃娃本文来源|搪瓷小娃娃博客园如我们所知#xff0c;Kubernetes通过 Volume 为集群中的容器提供存储#xff0c;通过Persistent Volume 和 Persistent Volume Claim实现Volume 的静态供给和动态供给。Azure File和Azure Disk 也在Kubernetes 支持的动态供给 … 本文作者|搪瓷小娃娃本文来源|搪瓷小娃娃博客园如我们所知Kubernetes通过 Volume 为集群中的容器提供存储通过Persistent Volume 和 Persistent Volume Claim实现Volume 的静态供给和动态供给。Azure File和Azure Disk 也在Kubernetes 支持的动态供给 PV 的 Provisioner之列如下图https://kubernetes.io/docs/concepts/storage/storage-classes/#provisioner本篇文章就带领大家操作一遍如何动态创建Azure File 文件共享以供集群中的多个Pod使用。1准备工作创建好一个AKS集群并且升级Azure CLI到最新版本登录到你创建好的集群中确认下各Node节点状态是否正常2添加StorageClass创建一个azure-file-sc.yaml文件并编辑如下如上我们创建的这个Storage Class封装的名称name为azurefile, provisioner指定为kubernetes.io/azure-file参数parameter部分指定冗余形式目前支持Standard的三张其他暂不支持Standard_LRS - standard locally redundant storage (LRS)Standard_GRS - standard geo-redundant storage (GRS)Standard_RAGRS - standard read-access geo-redundant storage (RA-GRS)创建好之后执行 kubectl apply -f azure-file-sc.yaml。3创建集群角色并绑定作为Azure平台上的服务AKS仍然使用的RBAC去控制集群的权限和安全。为了使Azure平台能够创建所需要的存储资源这一步我们需要添加一个集群角色---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata: name: system:azure-cloud-providerrules:- apiGroups: [] resources: [secrets] verbs: [get,create]---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata: name: system:azure-cloud-providerroleRef: kind: ClusterRole apiGroup: rbac.authorization.k8s.io name: system:azure-cloud-providersubjects:- kind: ServiceAccount name: persistent-volume-binder namespace: kube-system执行kubectl apply -f azure-pvc-roles.yaml 如下4创建PVC这一步就是动态申请存储资源的文件了命名这个PVC yaml文件为azure-file-pvc.yml编辑如下指定metadata为第2步中的StorageClassName,配置好访问模式和容量编辑好保存并运行可以看到这个PVC已经被成功创建。apiVersion: v1kind: PersistentVolumeClaimmetadata: name: azurefilespec: accessModes: - ReadWriteMany storageClassName: azurefile resources: requests: storage: 5Gi5使用并检验首先我们创建一个pod,命令为mypod1.yml,这个pod运行的是一个busybox镜像通过PVC将Azure File mount 到容器的/datatest目录中。apiVersion: v1kind: Podmetadata: name: mypod1spec: containers: - image: busybox name: mycontainer1 volumeMounts: - mountPath: /datatest name: datatest args: - /bin/sh - -c - sleep 30000 volumes: - name: datatest persistentVolumeClaim: claimName: my-azurefile-pvc然后依次执行kubectl apply -f mypod1.yaml#查看pod状态kubectl get pod -o wide#在pod里的datatest目录下创建一个名字为hello的文件kubectl exec mypod1 touch /datatest/hello如上是截图在pod中创建完名字为hello的文件后我们检验下这个文件有没有更新到Azure File中这里说明一下AKS动态配置完后的AzureFile会默认创建在MC_的集群中portal上找到这个存储账户进去找到Azure File下面的文件如截图发现hello.txt已经存在了。以上就是整个实验过程演示了AKS如何使用Azure File实现动态持久化存储。希望对大家有用。原文地址https://www.cnblogs.com/changruijun/p/10941339.html