云数据接入边缘卷配置

本文介绍 云接入边缘卷(包含本地清理的 blob 上传)的配置。

什么是云数据引入边缘存储卷?

云导入边缘卷 支持从边缘到 Blob 的无限数据导入,包括 ADLSgen2。 写入此存储类型的文件会无缝传输到 Blob 存储,并在确认上传后在本地清除。 此删除可确保新数据的空间可用性。 此外,此存储选项支持断开连接的环境中的数据完整性,这样在重新连接到网络时,本地存储和同步即可。

例如,可以将文件写入云导入 PVC,然后一个进程运行扫描每分钟检查是否有新文件。 标识后,文件将被发送以上传到您指定的 Blob 存储目标。 确认成功上传后,Cloud Ingest Edge 卷会等待 5 分钟,然后删除文件的本地版本。

先决条件

如果最终目标是 Blob 存储或 ADLSgen2,请继续遵循以下先决条件和说明。 如果最终目的地是 OneLake,请按照 替代:Cloud Ingest Edge Volumes 的 OneLake 配置中的说明进行操作。

  1. 按照此处的说明创建存储帐户。

    注释

    创建存储帐户时,建议在 Kubernetes 群集所在的资源组和区域/位置下创建存储帐户。

  2. 按照此处的说明,在之前创建的存储帐户中创建容器。

配置扩展标识

边缘卷允许使用系统分配的扩展标识来访问 Blob 存储。 本部分介绍如何使用系统分配的扩展标识授予对存储帐户的访问权限,以便将云流入卷上传到这些存储帐户中。

如果希望将工作负载标识与启用 Azure Arc 的 Azure 容器存储一起使用,请按照 云引入边缘卷中的工作负载标识说明进行操作。

获取扩展标识

Azure 门户

  1. 导航到已启用 Arc 的群集。
  2. 选择“扩展”。
  3. 选择通过 Azure Arc 扩展启用的 Azure 容器存储。
  4. 记下 群集扩展详细信息下的主体 ID。

为扩展标识配置 Blob 存储帐户

向存储帐户添加扩展标识权限

  1. 在 Azure 门户中导航到存储帐户。
  2. 选择“访问控制 (IAM)”
  3. 选择 “Add+ -> 添加角色分配”
  4. 选择 存储 Blob 数据所有者,然后选择 下一步
  5. 选择 +选择成员
  6. 要将您的主体 ID 添加到 所选成员: 列表中,请粘贴该 ID,然后选择其旁边的 +
  7. 单击“选择”。
  8. 若要查看和分配权限,请选择“ 下一步”,然后选择“ 审阅 + 分配”。

创建云引入永久性卷声明 (PVC)

  1. 创建包含以下内容的名为 cloudIngestPVC.yaml 的文件。 编辑 metadata.name 行,并为持久卷声明创建名称。 下一步中 deploymentExample.yaml 的最后一行将会引用此名称。 此外,请使用用于消耗的 Pod 更新该值 metadata.namespace。 如果没有预期使用的 Pod,则 metadata.namespace 值为 default。 该 spec.resources.requests.storage 参数确定永久性卷的大小。 此示例中为 2 GB,但可以修改以满足你的需求:

    注释

    只使用小写字母和短划线。 有关详细信息,请参阅 Kubernetes 对象命名文档

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      ### Create a name for your PVC ###
      name: <create-persistent-volume-claim-name-here>
      ### Use a namespace that matched your intended consuming pod, or "default" ###
      namespace: <intended-consuming-pod-or-default-here>
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 2Gi
      storageClassName: cloud-backed-sc
    
  2. 如果要应用 cloudIngestPVC.yaml,请运行:

    kubectl apply -f "cloudIngestPVC.yaml"
    

将子卷附加到边缘卷

若要使用扩展标识创建子卷以连接到存储帐户容器,请使用以下过程:

  1. 使用以下命令获取 Ingest Edge Volume 的名称:

    kubectl get edgevolumes
    
  2. 创建一个名为 edgeSubvolume.yaml 并复制以下内容的文件。 必须使用信息更新这些变量:

    注释

    只使用小写字母和短划线。 有关详细信息,请参阅 Kubernetes 对象命名文档

    • metadata.name:为子卷创建名称。
    • spec.edgevolume:此名称是使用 kubectl get edgevolumes 从上一步检索的。
    • spec.path:在装载路径下创建自己的子目录名称。 以下示例已包含示例名称(exampleSubDir)。 如果更改此路径名称,则必须使用新路径名称更新 deploymentExample.yaml 中的第 33 行。 如果选择重命名路径,请不要在前面使用斜杠。
    • spec.container:存储帐户中的容器名称。
    • spec.storageaccountendpoint:在 Azure 门户中导航到存储帐户。 在屏幕右上角的 “概述 ”页上,选择 “JSON 视图”。 可以在 storageaccountendpoint 下找到链接。 复制整个链接;例如, https://mytest.blob.core.windows.net/.
    apiVersion: "arccontainerstorage.azure.net/v1"
    kind: EdgeSubvolume
    metadata:
      name: <create-a-subvolume-name-here>
    spec:
      edgevolume: <your-edge-volume-name-here>
      path: exampleSubDir # If you change this path, line 33 in deploymentExample.yaml must be updated. Don't use a preceding slash.
      subvolumeType: INGEST 
      auth:
        authType: MANAGED_IDENTITY
      storageaccountendpoint: "https://<STORAGE ACCOUNT NAME>.blob.core.windows.net/"
      container: <your-blob-storage-account-container-name>
      ingestPolicy: edgeingestpolicy-default # Optional: See the following instructions if you want to update the ingestPolicy with your own configuration
    
  3. 如果要应用 edgeSubvolume.yaml,请运行:

    kubectl apply -f "edgeSubvolume.yaml"
    

可选:修改 ingestPolicy 默认值

  1. 要将 ingestPolicy 从默认的 edgeingestpolicy-default 更改,请创建一个名为 myedgeingest-policy.yaml 的文件,其中包含以下内容。 必须使用你的偏好设置更新以下变量:

    注释

    只使用小写字母和短划线。 有关详细信息,请参阅 Kubernetes 对象命名文档

    • metadata.name:为 ingestPolicy 创建名称。 必须在 spec.ingestPolicyedgeSubvolume.yaml 部分中更新并引用此名称。
    • spec.ingest.order:上传脏文件的顺序。 这是尽最大努力,而不是保证(默认为 最早优先)。 订单选项包括: 最早优先最新
    • spec.ingest.minDelaySec:脏文件符合引入条件前的最小秒数(默认值为 60)。 此数字可以介于 0 和 31536000 之间。
    • spec.eviction.order:如何逐出文件(默认值为 未排序)。 可用的逐出顺序选项有:无序从不
    • spec.eviction.minDelaySec:干净文件符合逐出条件前的秒数(默认值为 300)。 此数字可以介于 0 和 31536000 之间。
    apiVersion: arccontainerstorage.azure.net/v1
    kind: EdgeIngestPolicy
    metadata:
      name: <create-a-policy-name-here> # This must be updated and referenced in the spec.ingestPolicy section of the edgeSubvolume.yaml
    spec:
      ingest:
        order: <your-ingest-order>
        minDelaySec: <your-min-delay-sec>
      eviction:
        order: <your-eviction-order>
        minDelaySec: <your-min-delay-sec>
    

    有关这些规范的详细信息,请参阅 “设置引入策略”。

  2. 如果要应用 myedgeingest-policy.yaml,请运行:

    kubectl apply -f "myedgeingest-policy.yaml"
    

连接您的应用程序(Kubernetes 原生应用程序)

  1. 要针对永久性卷声明 (PVC) 配置通用单一 Pod(Kubernetes 本机应用程序),请创建包含以下内容的名为 deploymentExample.yaml 的文件。 修改containers.namevolumes.persistentVolumeClaim.claimName的值。 如果从 edgeSubvolume.yaml 更新了路径名称,则必须使用新路径名称更新第 33 行的 exampleSubDir。 该 spec.replicas 参数确定要创建的副本 Pod 数。 在此示例中为 2,但可以根据需要进行修改:

    注释

    只使用小写字母和短划线。 有关详细信息,请参阅 Kubernetes 对象命名文档

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: cloudingestedgevol-deployment ### This must be unique for each deployment 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/azure-cli:2.57.0@sha256:c7c8a97f2dec87539983f9ded34cd40397986dcbed23ddbb5964a18edae9cd09
              command:
                - "/bin/sh"
                - "-c"
                - "dd if=/dev/urandom of=/data/exampleSubDir/acsaingesttestfile count=16 bs=1M && while true; do ls /data &>/dev/null || break; sleep 1; done"
              volumeMounts:
                ### This name must match the volumes.name attribute below ###
                - name: wyvern-volume
                  ### This mountPath is where the PVC is attached to the pod's filesystem ###
                  mountPath: "/data"
          volumes:
             ### User-defined 'name' that's 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 (Line 5)
                claimName: <your-pvc-metadata-name-from-line-5-of-pvc-yaml>
    
  2. 如果要应用 deploymentExample.yaml,请运行:

    kubectl apply -f "deploymentExample.yaml"
    
  3. 使用 kubectl get pods 查找 Pod 的名称。 复制此名称以在下一步中使用。

    注释

    由于已将 spec.replicasdeploymentExample.yaml 指定为 2,因此会出现两个使用 kubectl get pods 的 Pod。 可以选择任一 Pod 名称用于下一步。

  4. 运行以下命令,并将 POD_NAME_HERE 替换为上一步中复制的值:

    kubectl exec -it POD_NAME_HERE -- sh
    
  5. 将目录更改为 /data 装载路径,该路径由 deploymentExample.yaml 指定。

  6. 您应该会看到一个目录,其中包含在“附加到边缘卷”部分的步骤 2 中指定的path名称。 将目录 /YOUR_PATH_NAME_HERE更改为,将 YOUR_PATH_NAME_HERE 值替换为详细信息。

  7. 例如,创建一个名为 file1.txt 的文件并使用 echo "Hello World" > file1.txt 写入它。

  8. 在 Azure 门户中,导航到您的存储帐户,找到在“将子卷附加至边缘卷”的步骤 2 中指定的容器。 选择容器时,应会发现容器中已填充 file1.txt。 如果文件尚未出现,请等待大约 1 分钟,Edge Volumes 在上传前会等待一分钟。

后续步骤

完成这些步骤后,您可以开始使用 Azure Monitor 和 Kubernetes 监控,或者使用 Prometheus 和 Grafana 进行第三方监控来监视您的部署。

监视部署