There are cases when you want to restart a specific container instead of deleting the pod and letting Kubernetes recreate it.
i am having one pod running apache container. i did editing in apache config file. for SSL certificate virtual host port changes etc.
now i want to restart apache2 service but without recreating pod.
i tried inside pod with
service apache2 restart
but it also recreate pod and configuration also change again.
2
Answers
check this
You can also create a new dockerfile for override the apache dockerfile and change de CMD line, but it’s more complicated
This is not how it supposed to work.
You should not change anything inside the
POD
.If your
POD
dies or crushes, Kubernetes should just start a new one and everything should work.Also keep in mind that you cannot scale the
POD
that had configuration altered.Please check the Kubernetes docs Configure a Pod to Use a ConfigMap
You can use
ConfigMap
to create configuration file.ConfigMap
can be created and read a content of a file :$ kubectl create configmap config_data --from-file=config_data.txt
or it can be declared in .yml
Also this might be done by creating a
secret
or
secret
can be declared:I recommend reading Kubernetes recipe: store nginx config with ConfigMap and reverse-proxy requests from your domain to your Github page.
There are also other options like mounting path with needed configuration on new
POD
.I advice you to check Configure a Pod to Use a PersistentVolume for Storage