Mounting a volume with kubectl
TL;DR I don't know what the issue was but I ended up solving this by making the build request very verbose.
I ended up solving this by setting debug to very verbose (v=0
) and noticing that my volume mount was completely ignored by kubectl
and not present in the request to the API:
I0929 13:31:22.429307 14616 request.go:897] Request Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"alpine","creationTimestamp":null,"labels":{"run":"alpine"}},"spec":{"volumes":[{"name":"store","emptyDir":{}}],"containers":[{"name":"alpine","image":"alpine:latest","args":["sh"],"resources":{},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent","stdin":true,"stdinOnce":true,"tty":true}],"restartPolicy":"Never","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{},"schedulerName":"default-scheduler"},"status":{}}
I copy pasted that request, and edited it to add the same volume mount as above, and it worked:
kubectl run -i --rm --tty alpine --overrides='{ "kind": "Pod", "apiVersion": "v1", "metadata": { "name": "alpine", "creationTimestamp": null, "labels": { "run": "alpine" } }, "spec": { "containers": [{ "name": "alpine", "image": "alpine:latest", "args": ["sh"], "resources": {}, "terminationMessagePath": "/dev/termination-log", "terminationMessagePolicy": "File", "imagePullPolicy": "IfNotPresent", "stdin": true, "stdinOnce": true, "tty": true, "volumeMounts": [{ "mountPath": "/home/store", "name": "store" }] }], "volumes": [{ "name":"store", "emptyDir":{} }], "restartPolicy": "Never", "terminationGracePeriodSeconds": 30, "dnsPolicy": "ClusterFirst", "securityContext": {}, "schedulerName": "default-scheduler" }, "status": {}}' --image=alpine:latest -v=9 --restart=Never -- sh