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, 2019 in Kubernetes by Liana

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 :

- readOnly: true
mountPath: /certs/server
name: my-new-server-cert
- name: server-cert
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, 2019 by Sirajul
• 59,230 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
• 52,360 points
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,300 points
0 votes
1 answer
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17, 2019 in Others by anonymous
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,532 views
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, 2019 in Kubernetes by Sirajul
• 59,230 points
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, 2019 in Kubernetes by Sirajul
• 59,230 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP