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

在AKS容器内配置Blobfuse访问Azure存储遇fuse设备未找到问题

在AKS中使用Blobfuse访问Azure存储的问题解答

一、手动在容器内安装Blobfuse是否为正确方案?

不是AKS环境下的推荐方案。AKS提供Azure Blob Storage CSI驱动,这是官方原生的存储挂载方案,无需在容器内手动安装Blobfuse、执行挂载命令,直接通过Kubernetes的PersistentVolume/PersistentVolumeClaim就能将Blob容器挂载到Pod,更符合K8s编排规范,稳定性和可维护性更高。

二、如何解决"fuse: device not found"错误?

如果你坚持使用手动挂载的方式,需要从节点内核、容器权限、镜像依赖三个层面排查修复:

1. 确认AKS节点内核已加载FUSE模块

容器共享宿主机的内核,所以首先要确保AKS节点的内核已经加载fuse模块:

  • 登录到AKS节点(需要集群管理员权限),执行modprobe fuse
  • 如果执行失败,说明节点OS镜像未包含fuse模块,需要更换AKS节点的OS版本(比如使用Ubuntu 22.04节点镜像,默认包含fuse模块)

2. 修正容器的安全上下文配置

你的Pod YAML缺少关键权限配置,需要补充以下内容:

apiVersion: v1
kind: Pod
spec:
  containers:
  - name: test
    image: my_ubuntu:20.04
    command: ['cat']
    securityContext:
      allowPrivilegeEscalation: true
      privileged: true  # 必须开启特权模式,才能访问宿主机设备和执行挂载
      capabilities:
        add: ["SYS_ADMIN"]  # 挂载FUSE需要该权限
      seccompProfile:
        type: Unconfined  # 解除seccomp限制,允许FUSE相关系统调用
    devices:
      - /dev/fuse
    volumeMounts:
      - name: fuse-dev
        mountPath: /dev/fuse
  volumes:
    - name: fuse-dev
      hostPath:
        path: /dev/fuse
        type: CharDevice

3. 确保镜像包含FUSE用户态工具

在构建Docker镜像时,务必安装FUSE的用户态依赖:

  • Ubuntu镜像:
    RUN apt-get update && apt-get install -y fuse blobfuse
    
  • Alpine镜像:
    RUN apk add --no-cache fuse blobfuse
    

三、推荐的AKS原生挂载方案(Blob CSI驱动)

使用官方CSI驱动是更优选择,步骤如下:

  1. 确认AKS集群已启用Blob CSI驱动:新建AKS集群时默认启用,现有集群可通过az aks update --name <cluster-name> --resource-group <rg-name> --enable-blob-driver启用
  2. 创建StorageClass:
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: azureblob
    provisioner: blob.csi.azure.com
    parameters:
      skuName: Standard_LRS
    reclaimPolicy: Delete
    volumeBindingMode: Immediate
    allowVolumeExpansion: true
    
  3. 创建PersistentVolumeClaim:
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: blob-pvc
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 10Gi
      storageClassName: azureblob
    
  4. 在Pod中挂载PVC:
    apiVersion: v1
    kind: Pod
    metadata:
      name: test-blob
    spec:
      containers:
        - name: test
          image: ubuntu:22.04
          command: ["sleep", "infinity"]
          volumeMounts:
            - name: blob-volume
              mountPath: /mnt/blob
      volumes:
        - name: blob-volume
          persistentVolumeClaim:
            claimName: blob-pvc
    

内容的提问来源于stack exchange,提问作者Emil Salageanu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 23:06:27