Does the container restart whenever a secret object is updated (kubectl apply -f mysecret.yml)?

0 votes
Does the container restart whenever a secret object is updated (kubectl apply -f mysecret.yml)? If not how is the new password applied to the database?
Jul 18 in Kubernetes by Liana
34 views

1 answer to this question.

0 votes
  • If you are mounting the secret as a volume into your pod, when the secret is updated the content will be updated in your pod, without the pod restarting. 

  • It's up to your application to detect that change and reload, or to write your own logic that rolls the pods if the secret changes.

  • volumeMount controls what part of the secret volume is mounted into a particular container (defaults to the root, containing all those files, but can point to a specific file using `subPath`), and where in the container it should be mounted with `mountPath`.

  • Example spec :

volumeMounts:
- readOnly: true
mountPath: /certs/server
name: my-new-server-cert
volumes:
- name: server-cert
secret:
secretName: mysecret
  • Also, it depends on how the secret is consumed by a container. 

  • If env vars, then no. If a volumeMount, then the file is updated in the container ready to be consumed by the service but it needs to reload the file. 

  • The container does not restart. if the secret is mounted as a volume it is updated dynamically. 

  • if it is an environment variable it stays as the old value until the container is restarted

answered Jul 18 by Sirajul
• 40,980 points

Related Questions In Kubernetes

0 votes
1 answer

Pods IP address from inside a container in the pod

Make sure that your pod yaml file ...READ MORE

answered Aug 29, 2018 in Kubernetes by Kalgi
• 45,870 points
195 views
0 votes
1 answer

Increasing the shm size of a kubernetes container

You cannot achieve this in kubernetes pod. ...READ MORE

answered Sep 12, 2018 in Kubernetes by ajs3033
• 7,280 points
1,140 views
0 votes
1 answer
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
3,390 views
+3 votes
1 answer
0 votes
1 answer

How to determine what is the status of a deployment ?

You could use kubectl get deployment <deployment>.  If ...READ MORE

answered Jul 12 in Kubernetes by Sirajul
• 40,980 points
43 views
0 votes
1 answer

Is it possible to force the pod to run on a specific node?

By default, anti-affinity is not attempted by ...READ MORE

answered Jul 15 in Kubernetes by Sirajul
• 40,980 points
64 views