You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Azurite和blob-csi-driver的Azure K8s本地开发环境搭建问题

本地K8s + Azurite + Blob CSI Driver 搭建方案

核心思路

Azure Blob CSI Driver虽主要针对AKS优化,但可通过自定义配置适配本地环境,核心是修改驱动启动参数、存储类与密钥配置,使其指向本地Azurite实例。

步骤1:确认Azurite的可访问性

  • 若Azurite部署在本地K8s集群内,记录其Service地址(例:azurite.default.svc.cluster.local:10000)
  • 若部署在集群外,确保集群节点能访问Azurite的IP与默认Blob服务端口10000

步骤2:自定义安装Blob CSI Driver

官方helm chart默认依赖AKS云环境变量,需覆盖配置以适配本地场景:

helm install blob-csi-driver azure-blob-csi-driver/azure-blob-csi-driver \
  --namespace kube-system \
  --set node.enableHostNetwork=true \
  --set cloud=AzurePublicCloud \
  --set controller.replicas=1 \
  --set node.tolerateAllTaints=true \
  --set storageaccount.name=devstoreaccount1 \
  --set storageaccount.key=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== \
  --set endpoint=http://<azurite-service-or-ip>:10000

替换<azurite-service-or-ip>为你的Azurite实际地址,集群内用Service名,集群外用节点可访问IP

步骤3:创建适配Azurite的存储类

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: azurite-blob
provisioner: blob.csi.azure.com
parameters:
  skuName: Standard_LRS
  storageAccount: devstoreaccount1
  endpoint: http://<azurite-service-or-ip>:10000
  csi.storage.k8s.io/provisioner-secret-name: azure-blob-secret
  csi.storage.k8s.io/provisioner-secret-namespace: kube-system
reclaimPolicy: Delete
volumeBindingMode: Immediate
mountOptions:
  - --file-cache-timeout-in-seconds=120

步骤4:创建存储账户密钥Secret

apiVersion: v1
kind: Secret
metadata:
  name: azure-blob-secret
  namespace: kube-system
stringData:
  accountname: devstoreaccount1
  accountkey: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
type: Opaque

步骤5:测试挂载功能

创建PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azurite-blob-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
  storageClassName: azurite-blob

创建测试Pod

apiVersion: v1
kind: Pod
metadata:
  name: test-azurite-blob
spec:
  containers:
    - name: test-container
      image: nginx
      volumeMounts:
        - name: azurite-blob-volume
          mountPath: /mnt/blob
  volumes:
    - name: azurite-blob-volume
      persistentVolumeClaim:
        claimName: azurite-blob-pvc

常见问题排查

  • 驱动Pod启动失败时,查看日志定位问题:kubectl logs -n kube-system <blob-csi-controller-pod-name>
  • 确认Azurite的10000端口已开放,集群内部署需确保Service正确暴露端口
  • 本地K8s集群(如kind)需开启hostNetwork,否则驱动可能无法访问集群外的Azurite

内容的提问来源于stack exchange,提问作者Shahar Frank

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 15:14:54