Can a volume be mounted to a running container in Kubernetes?

6/1/2020

If I have a running Kubernetes deployment with a container, without any mounted storage, running in one of the pods, is it possible to mount a volume to this container without redepoyling?

-- ejlouw
kubernetes

1 Answer

6/1/2020

Based on Updating a Deployment- Kuberentes

A Deployment’s rollout is triggered if and only if the Deployment’s Pod template (that is, .spec.template) is changed, for example, if the labels or container images of the template are updated. Other updates, such as scaling the Deployment, do not trigger a rollout.

Add a volume to a deployment involves add .spec.template.spec.volumes to deployment's pod template, will indeed trigger a redeployment of the pod.

Can you elaborate further on what you are trying to do? This might be another way to achieve what you are trying to do.

-- Yang
Source: StackOverflow