Hi, i am trying to mount a volume in a kubernetes...
# general
l
Hi, i am trying to mount a volume in a kubernetes deployment, but i am unable to get the deployment to start in the following configuration. i have tried removing the volume mounts, and the container starts without any issue. can someone advise on where i am going wrong?
Copy code
const name = `${defaultName}-nextcloud`;

    // Create a nextcloud Deployment
    const appLabels = { appClass: name };

    const volume = new aws.ebs.Volume(name, {
        availabilityZone: "us-west-2a",
        size: 3,
        encrypted: true,
        tags: {
            name: name,
        }
    });

    const deployment = new k8s.apps.v1.Deployment(name,
        {
            metadata: {
                namespace: namespaceName,
                labels: appLabels,
            },
            spec: {
                replicas: 1,
                selector: { matchLabels: appLabels },
                template: {
                    metadata: {
                        labels: appLabels,
                    },
                    spec: {
                        containers: [
                            {
                                name: name,
                                image: "nextcloud:latest",
                                ports: [{ name: "http", containerPort: 80 }],
                                volumeMounts: [{
                                    name: "nextcloud-volume",
                                    mountPath: "/var/www/html"
                                }]
                            }
                        ],
                        volumes: [
                            {
                                name: "nextcloud-volume",
                                awsElasticBlockStore: {
                                    volumeID: volume.id
                                }
                            }
                        ]
                    }
                }
            },
        },
        {
            provider: cluster.provider,
        }
    );
c
what’s the error?
l
i get:
Copy code
Diagnostics:
  kubernetes:apps:Deployment (architecture-nextcloud):
    error: Plan apply failed: 2 errors occurred:
    
    * Timeout occurred for 'architecture-nextcloud-v6c0og91'
    * Minimum number of Pods to consider the application live was not attained
c
what do the events say?
kubectl get event
if you’re getting it when you are trying to mount it is very likely you’re not able to mount the volume and your pods aren’t starting.
they’ll just kind of hang out if you don’t have a volume that matches, for exaample.
l
i thought that is why it doesnt start. i will setup
kubectl
now
c
I don’t understand.
All I’m saying is that pulumi is (probably accurately) reporting that your pods never became live.
l
oh ok. i will see what
kubectl get event
returns.
c
If there are no events related to these pods, you probably configured the volume wrong somehow.
l
the volume is configured exactly as in the code above. (that code is copy-pasted)
c
Sure, but my point is that if it failed to provision for whatever reason, it would not mount, and your pods will fail.
Also, wait
I’m not sure how the EBS volume mounting works in here, but are you sure that you want the EBS ID as formatted in
volume.id
?
if that name is wrong, that would cause the volume to not mount, and your pods would wait forever, and the kube events might not tell you
(since it’s supposed to be eventually consistent.
l
ahh ok. i didnt know that. if that is the case, then how do i mount an EBS volume in kubernetes?
c
I don’t know, I’ve never done it.
the k8s volume docs should tell you though
you might even be doing it right, but if your pods aren’t booting, that could be one reason.
another is that you could be provisioning the volume incorrectly. It’s hard to say.
l
it seems similar to:
<https://kubernetes.io/docs/concepts/storage/volumes/#awselasticblockstore>
, except i have not specified
fsType
. i will try that now.
c
it will probably involve a bit of trial and error, unfortunately.
this part of the API is difficult to deal with.
l
sure. thanks for your help. if there was a pulumi forum i could post the solution there (if i find it). i think this may be something someone else may struggle with. it would also make for nice search indexing. 🙂
c
@lemon-greece-30910 feel free to post an issue and then the solution. That’s probably best.
also cc @gorgeous-egg-16927 — we’re trying make pulumi more proactive when it notices these sorts of things. 🙂
there’s a looooong tail of them, but it would be great to be able to proactively say “hey your pods aren’t booting because they’re waiting for volume mounts”
something like that is in the roadmap, somewhere