GKE: How to mount a persistent volume

4/30/2018

I'm trying to run an application with persistent storage on GKE.

I've tried using Dynamic Persistent Storage but this will give me insufficient rights on the disc.

When I create a 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

These are create correctly on 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

But when I use the create claim in my Application I get an error.

# 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"

The error:

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.

I've tried the same concept on AKS with azure-files and this work without any problems.

What step am I missing on GKE?

UPDATE I Found whereto run the dmesg | tail command and got:

[ 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

It seems not all providers support the same mount options.

-- Yvonne Arnoldus
google-kubernetes-engine
kubernetes

1 Answer

4/30/2018
[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

These errors are not related to the provider, they are related to the filesystem type.

Kubernetes calls system to mount the volume with defined FS type and options. You set ext4 filesystem, but it is impossible to set dir_mode and file_mode options for ext[234] FS.

-- Anton Kostenko
Source: StackOverflow