你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Azure 运营商关系存储设备

Azure 运营商关系是基于计算服务器、存储设备和网络构造设备等基本构造构建的。 Azure 运营商关系存储设备表示机架上的持久性存储设备。

每个存储设备都包含多个存储装置,这些存储装置聚合在一起以提供单个存储池。 此存储池之后被分割成多个卷,这些卷作为块存储设备提供给计算服务器。 计算服务器可以将这些块存储设备用作其工作负载的持久性存储。 每个 Azure 运营商关系群集都预配了跨所有租户工作负载共享的单个存储设备。

Azure 运营商关系实例中的存储设备表示为 Azure 资源。 运营商有权像查看其他任何 Azure 资源一样查看其属性。

Kubernetes 存储类

Azure 运营商关系软件 Kubernetes 堆栈提供两种类型的存储。 运营商通过 Kubernetes StorageClass 机制对其进行选择。

StorageClass:nexus-volume

默认存储机制 nexus-volume 是大多数用户的首选。 其提供的性能和可用性级别最高。 但是,无法同时跨多个工作器节点共享卷。 运营商可以使用 Azure API 和门户通过卷资源访问和管理这些卷。

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: testPvc
  namespace: default
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 107Mi
  storageClassName: nexus-volume
  volumeMode: Block
  volumeName: testVolume
status:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 107Mi
  phase: Bound

StorageClass:nexus-shared

在需要共享文件系统的情况下,可以使用 nexus-shared 存储类。 此存储类可使同一 Nexus Kubernetes 群集中的多个 Pod 并发访问并共享同一卷,以此方式提供共享存储解决方案。 nexus-shared 存储类由一项 NFS 存储服务提供支持。 此 NFS 存储服务(存储池最大大小当前限制为 1TiB)可用于每个云服务网络 (CSN)。 附加到 CSN 的任何 Nexus Kubernetes 群集都可以从此共享存储池预配永久性卷。 Nexus 共享支持读写一次 (RWO) 和读写多次 (RWX) 访问模式。 这意味着,工作负载应用程序可以使用这两种访问模式之一来访问共享存储。

尽管 nexus-shared 的性能和可用性足以满足大多数应用,但我们建议 I/O 要求非常高的工作负载使用 nexus-volume 选项以获得最佳性能

读写一次 (RWO)

在读写一次 (RWO) 模式下,一次只能由一个节点或请求方装载 nexus-shared 卷。 当多个 Pod 在同一节点上运行时,ReadWriteOnce 访问模式仍允许多个 Pod 访问卷。

apiVersion: v1
items:
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: test-pvc
    namespace: default
  spec:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 5Gi
    storageClassName: nexus-shared
    volumeMode: Filesystem
    volumeName: TestVolume
  status:
    accessModes:
    - ReadWriteOnce
    capacity:
      storage: 5Gi
    phase: Bound

读写多次 (RWX)

在读写多次 (RWX) 模式下,多个节点或请求方可以同时装载 nexus-shared 卷。

apiVersion: v1
items:
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: test-pvc
    namespace: default
  spec:
    accessModes:
    - ReadWriteMany
    resources:
      requests:
        storage: 5Gi
    storageClassName: nexus-shared
    volumeMode: Filesystem
    volumeName: TestVolume
  status:
    accessModes:
    - ReadWriteMany
    capacity:
      storage: 5Gi
    phase: Bound

示例

使用 nexus-volume 存储类读写一次 (RWO)

以下清单显示的是在 ReadWriteOnce 模式下使用 nexus-volume 存储类创建具有 PersistentVolumeClaimTemplate 的 StatefulSet。

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: test-sts-rwo
  labels:
    app: test-sts-rwo
spec:
  serviceName: test-sts-rwo-svc
  replicas: 3
  selector:
    matchLabels:
      app: test-sts-rwo
  template:
    metadata:
      labels:
        app: test-sts-rwo
    spec:
      containers:
      - name: busybox
        command:
        - "/bin/sh"
        - "-c"
        - while true; do echo "$(date) -- $(hostname)" >> /mnt/hostname.txt; sleep 1; done
        image: busybox
        volumeMounts:
        - name: test-volume-rwo
          mountPath: /mnt/
  volumeClaimTemplates:
    - metadata:
        name: test-volume-rwo
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 10Gi
        storageClassName: nexus-volume

StatefulSet 的每个 Pod 都将创建一个 PersistentVolumeClaim。

# kubectl get pvc
NAME                             STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
test-volume-rwo-test-sts-rwo-0   Bound    pvc-e41fec47-cc43-4cd5-8547-5a4457cbdced   10Gi       RWO            nexus-volume   8m17s
test-volume-rwo-test-sts-rwo-1   Bound    pvc-1589dc79-59d2-4a1d-8043-b6a883b7881d   10Gi       RWO            nexus-volume   7m58s
test-volume-rwo-test-sts-rwo-2   Bound    pvc-82e3beac-fe67-4676-9c61-e982022d443f   10Gi       RWO            nexus-volume   12s
# kubectl get pods -o wide -w
NAME             READY   STATUS    RESTARTS   AGE     IP              NODE                                         NOMINATED NODE   READINESS GATES
test-sts-rwo-0   1/1     Running   0          8m31s   10.245.231.74   nexus-cluster-6a8c4018-agentpool2-md-vhhv6   <none>           <none>
test-sts-rwo-1   1/1     Running   0          8m12s   10.245.126.73   nexus-cluster-6a8c4018-agentpool1-md-27nw4   <none>           <none>
test-sts-rwo-2   1/1     Running   0          26s     10.245.183.9    nexus-cluster-6a8c4018-agentpool1-md-4jprt   <none>           <none>
# kubectl exec test-sts-rwo-0 -- cat /mnt/hostname.txt
Thu Nov  9 21:57:25 UTC 2023 -- test-sts-rwo-0
Thu Nov  9 21:57:26 UTC 2023 -- test-sts-rwo-0
Thu Nov  9 21:57:27 UTC 2023 -- test-sts-rwo-0

# kubectl exec test-sts-rwo-1 -- cat /mnt/hostname.txt
Thu Nov  9 21:57:19 UTC 2023 -- test-sts-rwo-1
Thu Nov  9 21:57:20 UTC 2023 -- test-sts-rwo-1
Thu Nov  9 21:57:21 UTC 2023 -- test-sts-rwo-1

# kubectl exec test-sts-rwo-s -- cat /mnt/hostname.txt
Thu Nov  9 21:58:32 UTC 2023 -- test-sts-rwo-2
Thu Nov  9 21:58:33 UTC 2023 -- test-sts-rwo-2
Thu Nov  9 21:58:34 UTC 2023 -- test-sts-rwo-2

使用 nexus-shared 存储类读写多次 (RWX)

以下清单显示的是在 ReadWriteMany 模式下使用 nexus-shared 存储类创建具有 PersistentVolumeClaim (PVC) 的 Deployment。 创建的 PVC 由部署的所有 Pod 共享,所有 Pod 可以同时使用它进行读写。

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test-volume-rwx
spec:
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 3Gi
  storageClassName: nexus-shared
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: test-deploy-rwx
  name: test-deploy-rwx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: test-deploy-rwx
  template:
    metadata:
      labels:
        app: test-deploy-rwx
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: kubernetes.azure.com/agentpool
                operator: Exists
                values: []
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: busybox
        command:
        - "/bin/sh"
        - "-c"
        - while true; do echo "$(date) -- $(hostname)" >> /mnt/hostname.txt; sleep 1; done
        image: busybox
        volumeMounts:
        - name: test-volume-rwx
          mountPath: /mnt/
      volumes:
      - name: test-volume-rwx
        persistentVolumeClaim:
          claimName: test-volume-rwx
...

应用之后,部署将有三个副本共享同一 PVC。

# kubectl get pvc
NAME                             STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
test-volume-rwx                  Bound    pvc-32f0717e-6b63-4d64-a458-5be4ffe21d37   3Gi        RWX            nexus-shared   6s
# kubectl get pods -o wide -w
NAME                             READY   STATUS    RESTARTS   AGE     IP               NODE                                         NOMINATED NODE   READINESS GATES
test-deploy-rwx-fdb8f49c-86pv4   1/1     Running   0          18s     10.245.224.140   nexus-cluster-6a8c4018-agentpool1-md-s2dh7   <none>           <none>
test-deploy-rwx-fdb8f49c-9zsjf   1/1     Running   0          18s     10.245.126.74    nexus-cluster-6a8c4018-agentpool1-md-27nw4   <none>           <none>
test-deploy-rwx-fdb8f49c-wdgw7   1/1     Running   0          18s     10.245.231.75    nexus-cluster-6a8c4018-agentpool2-md-vhhv6   <none>           <none>

从以下输出中可以看到,所有 Pod 都写入同一 PVC。

# kubectl exec test-deploy-rwx-fdb8f49c-86pv4 -- cat /mnt/hostname.txt
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-86pv4
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-9zsjf
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-wdgw7
Thu Nov  9 21:51:42 UTC 2023 -- test-deploy-rwx-fdb8f49c-86pv4

# kubectl exec test-deploy-rwx-fdb8f49c-9zsjf -- cat /mnt/hostname.txt
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-86pv4
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-9zsjf
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-wdgw7
Thu Nov  9 21:51:42 UTC 2023 -- test-deploy-rwx-fdb8f49c-86pv4

# kubectl exec test-deploy-rwx-fdb8f49c-wdgw7 -- cat /mnt/hostname.txt
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-86pv4
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-9zsjf
Thu Nov  9 21:51:41 UTC 2023 -- test-deploy-rwx-fdb8f49c-wdgw7
Thu Nov  9 21:51:42 UTC 2023 -- test-deploy-rwx-fdb8f49c-86pv4

存储设备状态

以下属性反映存储设备的操作状态:

  • Status 指示从存储设备派生的状态。 状态可能是 AvailableErrorProvisioning

  • Provisioning State 提供存储设备的当前预配状态。 预配状态可以是 SucceededFailedInProgress

  • Capacity 提供存储设备的总容量和已用容量。

  • Remote Vendor Management 指示是否为存储设备启用或禁用远程供应商管理。

存储设备操作

  • 列出存储设备:列出提供的资源组或订阅中的存储设备。
  • 显示存储设备:获取提供的存储设备的属性。
  • 更新存储设备:更新提供的存储设备的属性或标记。
  • 为存储设备启用/禁用远程供应商管理:为提供的存储设备启用或禁用远程供应商管理。

注意

客户无法直接创建或删除存储设备。 这些资源仅作为群集生命周期的实现来创建。 实现会阻止来自任何用户的创建或删除请求,并且仅允许内部/应用程序驱动的创建或删除操作。