Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes Persistent Volume Mount not found

I am trying to create and mount a volume but getting stuck.

This part creates the storage:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvclaim2
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: managed-premium
  resources:
    requests:
      storage: 5Gi

The following is a continuation of my deployment section:

volumeMounts:
- name: config
  mountPath: /config
  readOnly: true
args:
- --configfile=/config/traefik.toml


volumes:
  - name: config
    persistentVolumeClaim:
      claimName: pvclaim2
    configMap:
    name: traefik-config

I keep getting the below error message:

The Deployment "traefik-ingress-controller" is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: "config"

Any help is appreciated.

UPDATE:

Output from describe pv:

Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  certs:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  pvclaim101
    ReadOnly:   false
  config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      traefik-conf
    Optional:  false
  traefik-ingress-controller-token-6npxp:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  traefik-ingress-controller-token-6npxp
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age               From               Message
  ----     ------            ----              ----               -------
  Warning  FailedScheduling  1m (x25 over 2m)  default-scheduler  persistentvolumeclaim "pvclaim101" not found
like image 594
Rutnet Avatar asked Dec 20 '18 19:12

Rutnet


3 Answers

Looks like you have an indentation it's finding the VolumeMount but not the Volume. Something like this should work:

containers:
- image: your-image
  name: your-containers
  volumeMounts:
  - name: config
    mountPath: /config
    readOnly: true
  args:
  - --configfile=/config/traefik.toml
volumes:
  - name: config
    persistentVolumeClaim:
      claimName: pvclaim2
    configMap:
    name: traefik-config
like image 112
Rico Avatar answered Nov 09 '22 19:11

Rico


Im going to take a wild guess here, is your traefik ingress controller running in the same namespace as your pvc? Pvc are namespace scoped, in your example, it is in default namespace. Normally we deploy ingress into its own namespace like "ingress" and its other associated pods.

like image 3
Bal Chua Avatar answered Nov 09 '22 21:11

Bal Chua


Let's debug:

1) the name of your PersistentVolumeClaim is pvclaim2 and everything looks ok

2) VolumeMounts section looks ok. config is in read-only mode and it is correct for config.

3) volumes section describes that config volume's type is the persistentVolumeClaim and it links to the PVC pvclaim2 - ok!

4) Next we can see that config volume's type is the configMap along with the PersistentVolumeClaim at the same time...and that will be the reason of an errors in the future. Assuming you wanted to use config volume as a mount for configfile traefik.toml you don't need PVC (especially 5 gigabytes in read-only mode)

All you need to do is createconfigMap. Command syntax:

kubectl create configmap <map-name> <data-source>

In your case it could be done like this:

kubectl create configmap traefik-config --from-file=<your-local-path-to-file>/traefik.toml

Then you need to update your Deployment:

containers:
- image: your-image
  name: your-containers
  volumeMounts:
  - name: config
    mountPath: /config
    readOnly: true # as far as i know configmaps are read-only since 1.9.5
  - name: some-persistent-storage-name
    mountPath: /<some-mount-point-for-storage>

...

volumes:
  - name: config
    configMap:
      name: traefik-config
  - name: some-persistent-storage-name
    persistentVolumeClaim:
      claimName: pvclaim2
like image 2
Konstantin Vustin Avatar answered Nov 09 '22 20:11

Konstantin Vustin