kubernetes-csi / csi-driver-nfs

This driver allows Kubernetes to access NFS server on Linux node.
Apache License 2.0
814 stars 245 forks source link

mounter.SetupAt failed to check volume lifecycle mode: volume mode "Ephemeral" not supported by driver nfs.csi.k8s.io (only supports ["Persistent"]) #716

Closed lanss315425 closed 1 month ago

lanss315425 commented 1 month ago
apiVersion: v1
kind: Pod
metadata:
  name: nginx-nfs-inline-example
spec:
  containers:
    - image: 192.168.18.165:8443/library/nginx:1.25.2-alpine
      name: nginx
      ports:
        - containerPort: 80
          protocol: TCP
      volumeMounts:
        - mountPath: /var/www
          name: pvc-nginx
          readOnly: false
  volumes:
    - name: persistent-storage
      csi:
        driver: nfs.csi.k8s.io
        volumeAttributes:
          server: 192.168.18.165
          share: /nfsserver01
          mountOptions: "nfsvers=3,nolock"

errors:

root@jh-master01:~/test# kubectl describe pods nginx-nfs-inline-example
Name:             nginx-nfs-inline-example
Namespace:        default
Priority:         0
Service Account:  default
Node:             jh-work01/192.168.18.181
Start Time:       Mon, 22 Jul 2024 08:39:59 +0800
Labels:           <none>
Annotations:      <none>
Status:           Pending
IP:               
IPs:              <none>
Containers:
  nginx:
    Container ID:   
    Image:          192.168.18.165:8443/library/nginx:1.25.2-alpine
    Image ID:       
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-6cjfw (ro)
      /var/www from pvc-nginx (rw)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  pvc-nginx:
    Type:              CSI (a Container Storage Interface (CSI) volume source)
    Driver:            nfs.csi.k8s.io
    FSType:            
    ReadOnly:          false
    VolumeAttributes:      mountOptions=nfsvers=3,nolock
                           server=192.168.18.165
                           share=/nfsserver01
  kube-api-access-6cjfw:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason       Age               From               Message
  ----     ------       ----              ----               -------
  Normal   Scheduled    16s               default-scheduler  Successfully assigned default/nginx-nfs-inline-example to jh-work01
  Warning  FailedMount  0s (x6 over 16s)  kubelet            MountVolume.SetUp failed for volume "pvc-nginx" : kubernetes.io/csi: mounter.SetupAt failed to check volume lifecycle mode: volume mode "Ephemeral" not supported by driver nfs.csi.k8s.io (only supports ["Persistent"])

Kubernetes 1.26.13 csi v4.8.0

andyzhangx commented 1 month ago

@lanss315425 you could set --set feature.enableInlineVolume=true to enable inline volume in chart or delete and create new CSIDriver by yourself, this feature is disable by default.

apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
  name: nfs.csi.k8s.io
spec:
  attachRequired: false
  volumeLifecycleModes:
    - Persistent
   - Ephemeral
  fsGroupPolicy: File