Keeping pod volume mount configurable in Kubernetes

6/4/2019

Is it possible to keep the volume mount configurable, such that I can choose to mount any specific persistent volume claim during POD creation?

I have a list of volume claims and I’m looking to configure my PodSpec in a way that will let me decide which claim to use as a volume mount without having to modify the YAML every time.

It is fine with me to run an additional kubectl command on the cluster before creating a new pod.

-- divyanshm
kubernetes
kubernetes-pod

1 Answer

6/5/2019

Based on your description here and in slack https://kubernetes.slack.com/archives/C09NXKJKA/p1559740826069800

Firstly, there is no interactive way to deploy yamls which will let you choose during run-time. Yaml are delarative therefore, you declare and then apply. NO questions asked, unless you have syntax errors!

Secondly, if you are looking for a kubectl command which the Sysadm will apply on production. Then right after deploying the dev yaml, you can use a (something similar to your use case) kubectl patch [resource name example pod] --patch '{"spec":{"volumes":[{"name": "glusterfsvol","persistentVolumeClaim": {"claimName": "nameOfNewVolumeClaim"}}]}}'

Lastly, What would be more concrete in your use case is to use a different storageclass in your dev and another one in production. In that you can have the same pvc which point to a different storage as it is defined in that k8s cluster. refer docs

-- garlicFrancium
Source: StackOverflow