SMB 共享挂载在 Kubernetes 上但内容不可见(文件或目录)

SMB share mounted on Kubernetes but not content is visible (files or directories)

我在 windows 上有 SMB 共享,我正试图将其作为持久卷挂载到 Kubernetes 上。我使用了这个 cifs 插件 https://github.com/fstab/cifs 并将共享安装到 pod 上。在 运行 pod 中,当在共享文件夹中执行“ls”时,我没有看到任何共享内容,但我可以 cd 进入目录,也可以在共享中搜索文件。路径有效但无法浏览内容。

我使用下面提供的 pod yaml :

apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
   - name: busybox
   image: busybox
 command:
   - sleep
   - "3600"
imagePullPolicy: IfNotPresent
volumeMounts:
- name: test
  mountPath: /data
volumes:
 - name: test
flexVolume:
  driver: "fstab/cifs"
  fsType: "cifs"
  secretRef:
    name: "cifs-secret"
  options:
    networkPath: "//server/share"
    mountOptions: "dir_mode=0755,file_mode=0755,noperm"

我知道您需要使用 dir_mode=0755file_mode=0755:

为文件夹设置正确的权限
sudo mount -t cifs credentials=<credentials-files>,dir_mode=0755,file_mode=0755 //WIN_SHARE_IP/<share_name> /mnt/share

您可以访问此页面了解更多info