Kubernetes: Can I create configMap from a file in a PV to persist the configMap?

1/4/2022

let's say, creating a configMap with a file from an ephemeral pod A, will this configMap be deleted after pod A is deleted? If it's true, what about creating a configMap from a file in a PV? In this way, even if pod A is gone, the file that our configMap was created from still exists so that the configMap will be preserved.

-- Steve Wu
kubernetes

1 Answer

1/4/2022

let's say, creating a configMap with a file from an ephemeral pod A, will this configMap be deleted after pod A is deleted?

No, if you create the config map from one file and attach that configmap to POD, on the deletion of POD that configmap won't get deleted.

You can use it with other deployment or POD also in the future and the file will be saved inside the config map as it is unless you update it.

Any changes to POD or POD with PV won't affect the config map it's a different resource.

You can inject a file to POD or PV using configmap and update that file or do operations on that file, but those changes won't be saved in the configmap.

If you are using POD with PV, your configmap injected file to PV so now your POD has access to the file and your application is performing an operation on that file. If PV, PVC there then file will be there saved inside it but again those changes won't get done in configmap.

-- Harsh Manvar
Source: StackOverflow