12

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
Rutnet
  • 1,533
  • 5
  • 26
  • 48
  • Update added in response to request for new error message – Rutnet Dec 21 '18 at 00:38
  • well, the error indicates you didnt create pvc (or created it with a wrong name), fix that – 4c74356b41 Dec 21 '18 at 07:17
  • @Rutnet, i think it's time to edit your post with all the details (like Azure), all the attached files (Deployments/StatefulSets, PVC, StorageClass). The current state of your first post is terrible. Look at that by yourself. What do you see? I can see some "pieces" of .yaml manifests with name mismatch for different resources, incorrect indents and one error massage, which impossible to match with something due to there's no any resource file attached. Because of the current state of your post you'll never get enough useful help to fix your problems. – Konstantin Vustin Dec 24 '18 at 09:07

5 Answers5

9

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
Rico
  • 58,485
  • 12
  • 111
  • 141
  • I don't think this is it. Basically, the issue is that ConfigMap and PVC are two distinct volume types and I've been trying to describe them together. Once I treated them seperately this worked. However, the new issue is that the PVC is not recognised after deployment – Rutnet Dec 21 '18 at 00:20
  • Just added them to the original question – Rutnet Dec 21 '18 at 00:31
  • Where is your definition of pvclaim101 `? – Rico Dec 23 '18 at 17:36
3

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.

Bal Chua
  • 1,134
  • 9
  • 10
2

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
Konstantin Vustin
  • 6,521
  • 2
  • 16
  • 32
0

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.

Hansika Weerasena
  • 3,046
  • 1
  • 13
  • 22
  • This is on Azure, I don't need a separate PV. If I create the PVC, it auto-generates the PV from the inbuilt storage classes. – Rutnet Dec 21 '18 at 00:38
0

I've also encountered this error. Be sure that the PVC are pointing to the correct namespace, since PVCs are namespaced. PV aren't.