dynamically or programmatically unmount / detach a persistent volum claim from a kubernetes pod and assign (mount /attach ) it to another pod dynamically or programmatically unmount / detach a persistent volum claim from a kubernetes pod and assign (mount /attach ) it to another pod kubernetes kubernetes

dynamically or programmatically unmount / detach a persistent volum claim from a kubernetes pod and assign (mount /attach ) it to another pod


As Jonas mentioned in the comment, this action is not possible:

Nope, this is not possible. Pod-manifests is intended to be seen as immutable and pods as disposable resources.

Look at the definition of pods:

Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.

A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. A Pod's contents are always co-located and co-scheduled, and run in a shared context. A Pod models an application-specific "logical host": it contains one or more application containers which are relatively tightly coupled. In non-cloud contexts, applications executed on the same physical or virtual machine are analogous to cloud applications executed on the same logical host.

However, you can dynamically create new storage volumes. Kubernetes supports Dynamic Volume Provisioning:

Dynamic volume provisioning allows storage volumes to be created on-demand. Without dynamic provisioning, cluster administrators have to manually make calls to their cloud or storage provider to create new storage volumes, and then create PersistentVolume objects to represent them in Kubernetes. The dynamic provisioning feature eliminates the need for cluster administrators to pre-provision storage. Instead, it automatically provisions storage when it is requested by users.