5

I'm trying to install a nfs-client-provisioner and run a mongdb with it. Unfortunately, the nfs-client-provisioner hangs in ContainerCreating and says "Warning FailedMount 3m35s (x13 over 37m) kubelet Unable to attach or mount volumes: unmounted volumes=[nfs-client-root], unattached volumes=[nfs-client-root kube-api-access-lr9tl]: timed out waiting for the condition ".

  • The nfs server is configured on the same VPS machine (Debian 10).
  • I am able to mount and write files on the nfs server from a second vps with debian 10.
  • The cluster is setup with K0s
  • I have an error with the helm chart and manual installation.

Any help is apechiatet1 For Some more info see below:

Helm version:

version.BuildInfo{Version:"v3.8.2", GitCommit:"6e3701edea09e5d55a8ca2aae03a68917630e91b", GitTreeState:"clean", GoVersion:"go1.17.5"}

Kubernetes version:

Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.6", GitCommit:"ad3338546da947756e8a88aa6822e9c11e7eac22", GitTreeState:"clean", BuildDate:"2022-04-14T08:49:13Z", GoVersion:"go1.17.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5+k0s", GitCommit:"5ab78974affb1a76f1e5687aaa8b02aeac4380b8", GitTreeState:"clean", BuildDate:"2022-03-24T22:59:27Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"linux/amd64"}

k0s version: v1.23.5+k0s.0 worker added with:

token=$(k0s token create --role=worker)
docker run -d --name k0s-worker1 --hostname k0s-worker1 --privileged -v /var/lib/k0s docker.io/k0sproject/k0s:latest k0s worker $token

kubectl get nodes

NAME                   STATUS   ROLES           AGE   VERSION
k0s-worker9            Ready    <none>          42m   v1.23.5+k0s
v2202204173709187201   Ready    control-plane   43m   v1.23.5+k0s

kubectl get sc

NAME                  PROVISIONER                                   RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
managed-nfs-storage   k8s-sigs.io/nfs-subdir-external-provisioner   Delete          Immediate           false                  40m

/ect/exports

/data/nfs-storage *(rw,sync,no_root_squash,no_subtree_check,insecure)

Output with sudo k0s kubectl describe pod nfs-client-provisioner-6889579fdb-t7j74

Name:           nfs-client-provisioner-6889579fdb-t7j74
Namespace:      default
Priority:       0
Node:           k0s-worker9/172.17.0.2
Start Time:     Tue, 26 Apr 2022 08:45:49 +0200
Labels:         app=nfs-client-provisioner
                pod-template-hash=6889579fdb
Annotations:    kubernetes.io/psp: 00-k0s-privileged
Status:         Pending
IP:
IPs:            <none>
Controlled By:  ReplicaSet/nfs-client-provisioner-6889579fdb
Containers:
  nfs-client-provisioner:
    Container ID:
    Image:          gcr.io/k8s-staging-sig-storage/nfs-subdir-external-provisioner:v4.0.1
    Image ID:
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:
      PROVISIONER_NAME:  k8s-sigs.io/nfs-subdir-external-provisioner
      NFS_SERVER:        47.122.181.39
      NFS_PATH:          /data/nfs-storage
    Mounts:
      /persistentvolumes from nfs-client-root (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-lr9tl (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  nfs-client-root:
    Type:      NFS (an NFS mount that lasts the lifetime of a pod)
    Server:    47.122.181.39
    Path:      /data/nfs-storage
    ReadOnly:  false
  kube-api-access-lr9tl:
    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    18m                  default-scheduler  Successfully assigned default/nfs-client-provisioner-6889579fdb-t7j74 to k0s-worker9
  Warning  FailedMount  2m42s (x6 over 16m)  kubelet            Unable to attach or mount volumes: unmounted volumes=[nfs-client-root], unattached volumes=[nfs-client-root kube-api-access-lr9tl]: timed out waiting for the condition
  Warning  FailedMount  24s (x2 over 7m14s)  kubelet            Unable to attach or mount volumes: unmounted volumes=[nfs-client-root], unattached volumes=[kube-api-access-lr9tl nfs-client-root]: timed out waiting for the condition

command using helm:

 helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
    --set nfs.server=47.122.181.39 \
    --set nfs.path=/data/nfs-storage

without helm: from https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/v4.0.2/deploy

kubectl create -f rbac.yaml
kubectl create -f class.yaml
kubectl create -f deployment.yaml

class.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: k8s-sigs.io/nfs-subdir-external-provisioner # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
  archiveOnDelete: "false"

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-client-provisioner
  labels:
    app: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: gcr.io/k8s-staging-sig-storage/nfs-subdir-external-provisioner:v4.0.1
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: k8s-sigs.io/nfs-subdir-external-provisioner
            - name: NFS_SERVER
              value: 47.122.181.39
            - name: NFS_PATH
              value: /data/nfs-storage
      volumes:
        - name: nfs-client-root
          nfs:
            server: 47.122.181.39
            path: /data/nfs-storage

K0s cluster setup:

sudo curl -sSLf https://get.k0s.sh | sudo sh
sudo k0s install controller --enable-worker
sudo k0s start
sudo cp /var/lib/k0s/pki/admin.conf ~/admin.conf
export KUBECONFIG=~/admin.conf
token=$(k0s token create --role=worker)
docker run -d --name k0s-worker9 --hostname k0s-worker9 --privileged -v /var/lib/k0s docker.io/k0sproject/k0s:latest k0s worker $token

Srividya
  • 1,678
  • 3
  • 10
Rabens
  • 61
  • 1
  • 3

1 Answers1

-1

Have you tried:

nfs.mountOptions = {
  nfsvers = 4
}

I also used this provisioner. It works only with nfs4. And also check mount point of your NFS server if it's root / or not. If your provisioner is configured and ready try to recreate pvc.

  • 1
    I recommend against rhetoric questions in answers. They risk being misunderstood as not an answer at all. You are trying to answer the question at the top of this page, aren't you? Otherwise please delete this post. – Yunnosch Jul 27 '22 at 09:58
  • switched to docker swarm due to less complexity. Thanks for the answer – Rabens Nov 16 '22 at 19:18
  • Where should this config be set? The response is related to the nfs-provisioner configuration, to the NFS server or to the NFS client config? Being less rhetoric and more informative regarding the question would be more usefull to others. – Luis Vazquez Mar 27 '23 at 19:34