Question

Unable to attach or mount volumes

Unable to attach or mount volumes: unmounted volumes=[code], unattached volumes=[code kube-api-access-fkxm9]: timed out waiting for the condition

Attach failed for volume “pvc” : Attach timeout for volume

Error from server (BadRequest): container “nginx” in pod “nginx-8589fdb7c-ktjcg” is waiting to start: ContainerCreating

Using this same content : https://www.digitalocean.com/community/tutorials/how-to-deploy-a-php-application-with-kubernetes-on-ubuntu-16-04

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

Is this on a Managed Kubernetes cluster? If so, you would need to use the following configuration:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: my-csi-app-set
spec:
  selector:
    matchLabels:
      app: mypod
  serviceName: "my-frontend"
  replicas: 1
  template:
    metadata:
      labels:
        app: mypod
    spec:
      containers:
      - name: my-frontend
        image: busybox
        args:
        - sleep
        - infinity
        volumeMounts:
        - mountPath: "/data"
          name: csi-pvc
  volumeClaimTemplates:
  - metadata:
      name: csi-pvc
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 5Gi
      storageClassName: do-block-storage

For more information on this, you could take a look at the official documentation here:

https://docs.digitalocean.com/products/kubernetes/how-to/add-volumes/

Best, Bobby