0

Some of our services in our K8s (EKS) envirnment use config files to drive functionality so we don't have to redeploy the whole image each time. Using kubectl cp command allows us to copy new config files to the pod. So the command kubectl cp settings.json myapi-76dc75f47c-lkvdm:/app/settings.json copies the new settings.json file to the pod.

For fun I deleted the pod and k8s recreated it successfully with the old settings.json file. Anyone know a way of keeping the new settings.json file if the pod gets destroyed? Is there a way to update the deployment without redeploying the image?

Thanks, Tim

chd
  • 25
  • 4

1 Answers1

2

Store the config file inside a ConfigMap and mount the ConfigMap to Deployment's pod template. When the file needs updating, either:

  1. Re-create the ConfigMap (kubectl delete then kubectl create --from-file)
  2. Or use the "dry-run kubectl create piped into kubectl replace" technique from https://stackoverflow.com/a/38216458/34586
Lukman
  • 18,462
  • 6
  • 56
  • 66