繁体   English   中英

GKE:如何挂载持久卷

[英]GKE: How to mount a persistent volume

我正在尝试在 GKE 上运行具有持久存储的应用程序。

我尝试过使用动态持久存储,但这会给我在磁盘上的权限不足。

当我创建一个 StorageClass、PersistentVolume 和 PersistentVolumeClaim

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: documentation-7-x-storageclass
  labels:
     product: "documentation-7-x"
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-standard
  zone: europe-west1-b

apiVersion: v1
kind: PersistentVolume
metadata:
  name: documentation-7-x-volume
  labels:
     product: "documentation-7-x"
spec:
  capacity:
    storage: 500Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: documentation-7-x-storageclass
  persistentVolumeReclaimPolicy: Retain
  gcePersistentDisk: 
    fsType: "ext4" 
    pdName: "documentationstorage"
  mountOptions:
  - dir_mode=0777
  - file_mode=0777

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: documentation-7-x-volume-claim
  labels:
     product: "documentation-7-x"  
spec:
  volumeName: documentation-7-x-volume
  storageClassName: documentation-7-x-storageclass
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

这些是在 GKE 上正确创建的。

kubectl get pv
NAME                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS    CLAIM                                    STORAGECLASS                     REASON    AGE
documentation-7-x-volume   500Gi      RWO            Retain           Bound     default/documentation-7-x-volume-claim   documentation-7-x-storageclass             3m

但是当我在我的应用程序中使用 create 声明时,我得到一个错误。

# Create a deployment for the Documentation
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: documentation-7-x
  labels:
    product: "documentation-7-x"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: documentation-7-x
      product: "documentation-7-x"
  template:
    metadata:
      labels:
        app: documentation-7-x
        product: "documentation-7-x"
    spec: 
      volumes:
      - name: documentation-7-x-volume
        persistentVolumeClaim:
          claimName: documentation-7-x-volume-claim
      containers:
      - name: documentation-7-x
        image: atlassian/confluence-server:6.3.2
        imagePullPolicy: Always
        ports:
        - containerPort: 8090
        # Mount the volume claimed above
        volumeMounts:
        - name: documentation-7-x-volume
          mountPath: /var/atlassian/application-data/confluence
---
# Create service for the Documentation
apiVersion: v1
kind: Service
metadata:
  name: documentation-7-x-service
  labels:
    product: "documentation-7-x"
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8090
  selector:
    app: documentation-7-x
    product: "documentation-7-x"

错误:

MountVolume.MountDevice failed for volume "documentation-7-x-volume" : mount failed: exit status 32 Mounting command: systemd-run Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/fontoxmldocumentstorage --scope -- mount -t ext4 -o dir_mode=0777,file_mode=0777,defaults /dev/disk/by-id/google-fontoxmldocumentstorage /var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/fontoxmldocumentstorage Output: Running scope as unit: run-r49218112baa6471a8b4a3e2b4ad68aaa.scope mount: wrong fs type, bad option, bad superblock on /dev/sdb, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.

我已经在 AKS 上使用 azure-files 尝试了相同的概念,并且这项工作没有任何问题。

我在 GKE 上缺少什么步骤?

更新我发现在哪里运行dmesg | tail dmesg | tail命令并得到:

[ 9793.897427] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value
[ 9797.046199] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value
[ 9802.139814] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value
[ 9811.333114] EXT4-fs (sdb): Unrecognized mount option "file_mode=0777" or missing value
[ 9828.747800] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value
[ 9862.074279] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value
[ 9927.399967] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value
[10050.664769] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value
[10173.955638] EXT4-fs (sdb): Unrecognized mount option "file_mode=0777" or missing value
[10297.281253] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value

似乎并非所有提供商都支持相同的挂载选项。

 [10050.664769] EXT4-fs (sdb): Unrecognized mount option "dir_mode=0777" or missing value [10173.955638] EXT4-fs (sdb): Unrecognized mount option "file_mode=0777" or missing value 

这些错误与提供程序无关,它们与文件系统类型有关。

Kubernetes调用系统以使用已定义的FS类型和选项装载卷。 您设置了ext4文件系统,但是无法为ext [234] FS 设置 dir_modefile_mode选项。

我在 GKE 上遇到了类似的事情。 GCP 支持提供的解决方案是删除似乎会干扰 GKE CSI 驱动程序的 OpenEBS(类似于 Longhorn 的卷配置器)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM