使用 cifs 挂载 SMB 共享时出现 K8s pod “Output: mount error(107): Transport endpoint is not connected”

K8s pod "Output: mount error(107): Transport endpoint is not connected" when mounting SMB share with cifs

提问人:Roger 提问时间:9/20/2023 最后编辑:Roger 更新时间:9/21/2023 访问量:109

问:

我正在尝试使用以下方法在 k8s pod 中挂载 SMB 共享:

使用密钥中的用户和密码连接到 SMB 共享的 PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: smb-volume
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  mountOptions:
    - dir_mode=0777
    - file_mode=0777
    - vers=3.0
  csi:
    driver: smb.csi.k8s.io
    readOnly: false
    volumeHandle: smb-volume
    volumeAttributes:
      source: "//<SMB-SHARE-ADDRESS>/shared-data"
    nodeStageSecretRef:
      name: <SECRET-NAME>
      namespace: <SECRET-NAMESPACE>

绑定到 PV 的 PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: smb-pvc
  namespace: <PVC-NAMESPACE>
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
  volumeName: smb-volume
  storageClassName: ""

使用以下代码挂载 PVC 的部署:

spec:
  replicas: 1
  template:
    spec:
      containers:
        - name: <CONTAINER-NAME>
          volumeMounts:
          - name: share
            mountPath: /home/user/share
      volumes:
      - name: share
        persistentVolumeClaim:
          claimName: smb-pvc

我安装了 smb.csi.k8s.io 驱动程序,如下所示:

SMB CSI installed

我在 5 个集群中应用此解决方案。其中四个成功了。其中一个(生产)出现以下错误:

kind: Event
apiVersion: events.k8s.io/v1
metadata:
  name: <EVENT-NAME>
  namespace: <NAMESPACE>
eventTime: null
reason: FailedMount
regarding:
  kind: Pod
  namespace: <NAMESPACE>
  name: <POD-NAME>
  apiVersion: v1
note: >
  MountVolume.MountDevice failed for volume "smb-volume" : rpc error:
  code = Internal desc = volume(smb-volume) mount
  "//<SMB-SHARE-ADDRESS>/shared-data" on
  "/var/lib/kubelet/plugins/kubernetes.io/csi/smb.csi.k8s.io/0f464fd4331cbcb83be21b563baad7a7227e7e6e6a0a6f33380040bd1e0bddfc/globalmount"
  failed with mount failed: exit status 32

  Mounting command: mount

  Mounting arguments: -t cifs -o dir_mode=0777,file_mode=0777,vers=3.0,<masked>
  //<SMB-SHARE-ADDRESS>/shared-data
  /var/lib/kubelet/plugins/kubernetes.io/csi/smb.csi.k8s.io/0f464fd4331cbcb83be21b563baad7a7227e7e6e6a0a6f33380040bd1e0bddfc/globalmount

  Output: mount error(107): Transport endpoint is not connected

  Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log
  messages (dmesg)
type: Warning
deprecatedSource:
  component: kubelet
  host: aks-system2-23099442-vmss000003
deprecatedFirstTimestamp: '2023-09-18T16:43:12Z'
deprecatedLastTimestamp: '2023-09-18T16:43:45Z'
deprecatedCount: 7

我已经检查过的东西:

  • SMB 共享是可访问的,我可以通过我的计算机或使用其他环境之一来装载它
  • SMB 共享是从此特定环境中的 pod 内部打开的,我使用nc -zv <SAMBA-SHARE> <PORT>
  • 我无法在 pod 中执行 dmesg

有什么想法吗?

--更新--

我从执行中收到此消息

dmesg | grep CIFS

在运行 Pod 的节点内:

[2869212.915113] CIFS: Attempting to mount \\<SMB-SHARE-ADDRESS>\shared-data
[2869212.927925] CIFS: VFS: \\<SMB-SHARE-ADDRESS> smb3_crypto_aead_allocate: Failed alloc encrypt aead
[2869212.931552] CIFS: VFS: \\<SMB-SHARE-ADDRESS> crypt_message: crypto alloc failed
[2869212.934458] CIFS: VFS: \\<SMB-SHARE-ADDRESS> failed to connect to IPC (rc=-2)
[2869212.937337] CIFS: VFS: session 00000000920e8221 has no tcon available for a dfs referral request
[2869212.942989] CIFS: VFS: \\<SMB-SHARE-ADDRESS> smb3_crypto_aead_allocate: Failed alloc encrypt aead
[2869212.946427] CIFS: VFS: \\<SMB-SHARE-ADDRESS> crypt_message: crypto alloc failed
[2869212.949261] CIFS: VFS: \\<SMB-SHARE-ADDRESS> __cifs_put_smb_ses: Session Logoff failure rc=-2
[2869212.952415] CIFS: VFS: cifs_mount failed w/return code = -107

如果我从节点内执行以下命令,我还可以挂载文件共享:

mount -t cifs //<SMB-SHARE-ADDRESS>/shared-data temp -o username=<SMB-SHARE-USER>,password=<SMB-SHARE-PASSWORD>,domain=<SMB-SHARE>
Azure Kubernetes Samba CIFS

评论


答: 暂无答案