'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
Solution 1:[1]
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
Solution 2:[2]
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.
Solution 3:[3]
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
Solution 4:[4]
This is because there is no PersistentVolume(PV) to be bound to that PersistentVolumeClaim(PVC). This can be due to several reasons.
One thing is you haven't created a PV for the claim. A PVC need to have a PV to be claimed. If that so first you need to create a Persistance volume of any type of multiple types supported by kubernets. An example of PV using a nfs can be found here.
The second reason may be that any parameter of any of the existing and unbound PV is not matched with PVC. So check whether the storage capacity, access modes, storage class and labels of PV and PVC are matched. As an example if you want your PVC of the storageClassName: managed-premium
make sure that your PV also have the storage Class Type.
And the last thing may be the PV that you think there is and match all parameters with PVC bound to some other PVC. PV is an atomic abstraction and you cannot use one PV for multiple PVCs.
You can use kubectl get pv
to check whether there are volumes which has STATUS available and matching the PVCs requirements.
Solution 5:[5]
I've also encountered this error. Be sure that the PVC are pointing to the correct namespace, since PVCs are namespaced. PV aren't.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rico |
Solution 2 | Bal Chua |
Solution 3 | Konstantin Vustin |
Solution 4 | |
Solution 5 | Asher Manangan |