azure - 获取 : bad option; for several filesystems (e. g。 nfs、cifs)尝试在 K8 容器中挂载 azure 文件共享时

标签 azure kubernetes azure-aks persistent-volumes azure-files

我创建了一个 Azure 文件共享,并且可以使用 Windows 10 笔记本电脑中的映射网络驱动器连接到它。我创建了一个 hello-world Spring Boot 应用程序,其中包含用于 azure 文件共享的卷安装配置,并尝试部署在docker-desktop 中的 Kubernetes。但我的 Pod 没有启动 -

hello-world-9d7479c4d-26mv2   0/1     ContainerCreating   0          15s

这是我在描述 POD 时在事件中看到的错误 -

Events:
  Type     Reason       Age              From                     Message
  ----     ------       ----             ----                     -------
  Normal   Scheduled    9h                                        Successfully assigned default/hello-world-9d7479c4d-26mv2 to docker-desktop
  Warning  FailedMount  9h (x7 over 9h)  kubelet, docker-desktop  MountVolume.SetUp failed for volume "fileshare-pv" : mount failed: exit status 32
Mounting command: mount
Mounting arguments: -t cifs -o file_mode=0777,dir_mode=0777,vers=3.0,<masked> //mystorage.file.core.windows.net/myshare /var/lib/kubelet/pods/425012d1-13ee-4c40-bf40-d2f7ccfe5954/volumes/kubernetes.io~azure-file/fileshare-pv
Output: mount: /var/lib/kubelet/pods/425012d1-13ee-4c40-bf40-d2f7ccfe5954/volumes/kubernetes.io~azure-file/fileshare-pv: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.

然后我更新了 Dockerfile 以安装 cifs-utils -

FROM ubuntu:16.04
# Install Java
RUN apt-get update && \
    apt-get install -y openjdk-8-jdk && \
    apt-get install -y ant && \
    apt-get install -y cifs-utils && \
    apt-get clean;

ENV PORT 8080
EXPOSE 8080
COPY target/*.jar /opt/app.jar
WORKDIR /opt
CMD ["java", "-jar", "app.jar"]

那个错误仍然没有消失。我用谷歌搜索了很多解决方案,但没有运气。在 docker-desktop [windows 机器] 中使用 azure 文件共享与 kubernates 容器是否有任何限制?

这是我的 K8 配置 -

secret.yaml

apiVersion: v1
kind: Secret
metadata:
  name: storage-secret
  namespace: default
type: Opaque
data:
  azurestorageaccountname: BASE64-encoded-account-name
  azurestorageaccountkey: BASE64-encoded-account-key

pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: fileshare-pv
  labels:
    usage: fileshare-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  azureFile:
    secretName: storage-secret
    shareName: myshare
    readOnly: false

pvc.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: fileshare-pvc
  namespace: default
  # Set this annotation to NOT let Kubernetes automatically create
  # a persistent volume for this volume claim.
  annotations:
    volume.beta.kubernetes.io/storage-class: ""
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
  selector:
    # To make sure we match the claim with the exact volume, match the label
    matchLabels:
      usage: fileshare-pv

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world
  namespace: default
  labels:
    app: hello-world
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hello-world
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
        - name: hello-world-pod
          image: 'hello-world-k8:1.0'
          volumeMounts:
          - name: azure
            mountPath: /azureshare
          ports:
            - containerPort: 8080
      volumes:
      - name: azure
        persistentVolumeClaim:
          claimName: fileshare-pvc      
---
apiVersion: v1
kind: Service
metadata:
  name: hello-world-service
  namespace: default
spec:
  selector:
    app: hello-world
  ports:
  - name: http
    protocol: TCP
    port: 8080
    targetPort: 8080
  type: LoadBalancer

最佳答案

您可能需要安装一个知道如何挂载该文件系统的软件包。对于 NFS,这可能是 Debian/Ubuntu 的 nfs-common。

sudo apt update && sudo apt install nfs-common -y

关于azure - 获取 : bad option; for several filesystems (e. g。 nfs、cifs)尝试在 K8 容器中挂载 azure 文件共享时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66145158/

相关文章:

Azure kubernetes - 如何安装 spinnaker?

azure - 是否建议在非工作时间将 AKS 用户节点池缩减至 0?

azure - 入口资源文件错误 AKS - spec.rules[0].http.paths[0].pathType : Required value: pathType must be specified

azure - 如何在azure存储帐户中创建子文件夹并使用azure功能应用程序复制文件

kubernetes - 如何在现有 Kubernetes 集群上启用 RBAC

configuration - Kubernetes 根据命名空间设置环境变量

kubernetes - 无法在docker或本地上构建或测试kubernetes

azure - 流量管理器+ azure 网站: how do I configure custom dns ssl

azure - 是否有任何 PowerShell 命令可以获取已分配或未分配 JIT(即时)的所有 Azure VM 的详细信息?

azure - 使用流分析将数据从 IoT 中心传输到 Cosmos DB 会出现分区错误