https://pulumi.com logo
#general
Title
# general
l

lemon-greece-30910

03/06/2019, 9:28 PM
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

creamy-potato-29402

03/06/2019, 9:29 PM
what’s the error?
l

lemon-greece-30910

03/06/2019, 9:31 PM
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

creamy-potato-29402

03/06/2019, 9:32 PM
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

lemon-greece-30910

03/06/2019, 9:34 PM
i thought that is why it doesnt start. i will setup
kubectl
now
c

creamy-potato-29402

03/06/2019, 9:34 PM
I don’t understand.
All I’m saying is that pulumi is (probably accurately) reporting that your pods never became live.
l

lemon-greece-30910

03/06/2019, 9:36 PM
oh ok. i will see what
kubectl get event
returns.
c

creamy-potato-29402

03/06/2019, 9:38 PM
If there are no events related to these pods, you probably configured the volume wrong somehow.
l

lemon-greece-30910

03/06/2019, 9:41 PM
the volume is configured exactly as in the code above. (that code is copy-pasted)
c

creamy-potato-29402

03/06/2019, 9:41 PM
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

lemon-greece-30910

03/06/2019, 9:46 PM
ahh ok. i didnt know that. if that is the case, then how do i mount an EBS volume in kubernetes?
c

creamy-potato-29402

03/06/2019, 9:46 PM
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

lemon-greece-30910

03/06/2019, 9:48 PM
it seems similar to:
<https://kubernetes.io/docs/concepts/storage/volumes/#awselasticblockstore>
, except i have not specified
fsType
. i will try that now.
c

creamy-potato-29402

03/06/2019, 9:49 PM
it will probably involve a bit of trial and error, unfortunately.
this part of the API is difficult to deal with.
l

lemon-greece-30910

03/06/2019, 9:52 PM
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

creamy-potato-29402

03/06/2019, 9:53 PM
@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