你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
本文介绍如何在 Azure Arc 启用的 Azure 容器存储中配置本地共享边缘卷(高度可用、持久本地存储)。
创建本地共享边缘卷永久性卷声明 (PVC),并针对 PVC 配置 Pod
- 创建包含以下内容的名为 - localSharedPVC.yaml的文件。 使用永久性卷声明的名称修改- metadata.name值。 然后,在第 8 行中指定与预期使用的 Pod 匹配的命名空间。 在下一步,- metadata.name的最后一行引用了- deploymentExample.yaml的值。 该- spec.resources.requests.storage参数确定永久性卷的大小。 此示例中为 2 GB,但可以修改以满足你的需求:- 注释 - 只使用小写字母和短划线。 有关详细信息,请参阅 Kubernetes 对象命名文档。 - kind: PersistentVolumeClaim apiVersion: v1 metadata: ### Create a name for your PVC ### name: <create-a-pvc-name-here> ### Use a namespace that matches your intended consuming pod, or "default" ### namespace: <intended-consuming-pod-or-default-here> spec: accessModes: - ReadWriteMany resources: requests: storage: 2Gi storageClassName: unbacked-sc
- 创建包含以下内容的名为 - deploymentExample.yaml的文件。 为- containers.name和- volumes.persistentVolumeClaim.claimName添加值。 该- spec.replicas参数确定要创建的副本 Pod 数。 在此示例中为 2,但可以根据需要进行修改:- 注释 - 只使用小写字母和短划线。 有关详细信息,请参阅 Kubernetes 对象命名文档。 - apiVersion: apps/v1 kind: Deployment metadata: name: localsharededgevol-deployment ### This will need to be unique for every volume you choose to create spec: replicas: 2 selector: matchLabels: name: wyvern-testclientdeployment template: metadata: name: wyvern-testclientdeployment labels: name: wyvern-testclientdeployment spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: app operator: In values: - wyvern-testclientdeployment topologyKey: kubernetes.io/hostname containers: ### Specify the container in which to launch the busy box. ### - name: <create-a-container-name-here> image: 'mcr.microsoft.com/mirror/docker/library/busybox:1.35' command: - "/bin/sh" - "-c" - "dd if=/dev/urandom of=/data/acsalocalsharedtestfile count=16 bs=1M && while true; do ls /data &>/dev/null || break; sleep 1; done" volumeMounts: ### This name must match the following volumes::name attribute ### - name: wyvern-volume ### This mountPath is where the PVC will be attached to the pod's filesystem ### mountPath: /data volumes: ### User-defined name that is used to link the volumeMounts. This name must match volumeMounts::name as previously specified. ### - name: wyvern-volume persistentVolumeClaim: ### This claimName must refer to your PVC metadata::name from lsevPVC.yaml. claimName: <your-pvc-metadata-name-from-line-5-of-pvc-yaml>
- 若要应用这些 YAML 文件,请运行: - kubectl apply -f "localSharedPVC.yaml" kubectl apply -f "deploymentExample.yaml"
- 运行 - kubectl get pods以查找 Pod 的名称。 复制此名称,以便在下一步中使用它。- 注释 - 由于已将 - spec::replicas的- deploymentExample.yaml指定为- 2,因此会出现两个使用- kubectl get pods的 Pod。 可以选择任一 Pod 名称用于下一步。
- 运行以下命令,并将 - POD_NAME_HERE替换为上一步复制的值:- kubectl exec -it pod_name_here -- sh
- 将目录更改为 - /data挂载路径,按照- deploymentExample.yaml中的指定。
- 例如,创建一个名为 - file1.txt的文件并使用- echo "Hello World" > file1.txt写入它。
完成上述步骤后,使用 Azure Monitor 和 Kubernetes 监视或其他监视工具(如 Prometheus 或 Grafana)开始监视部署。