Restart pods when configmap updates in Kubernetes?

后端 未结 7 2127
猫巷女王i
猫巷女王i 2020-11-29 16:51

How do I automatically restart Kubernetes pods and pods associated with deployments when their configmap is changed/updated?


I know there\'s been talk about th

7条回答
  •  长情又很酷
    2020-11-29 17:13

    The best way I've found to do it is run Reloader

    It allows you to define configmaps or secrets to watch, when they get updated, a rolling update of your deployment is performed. Here's an example:

    You have a deployment foo and a ConfigMap called foo-configmap. You want to roll the pods of the deployment every time the configmap is changed. You need to run Reloader with:

    kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml
    

    Then specify this annotation in your deployment:

    kind: Deployment
    metadata:
      annotations:
        configmap.reloader.stakater.com/reload: "foo-configmap"
      name: foo
    ...
    

提交回复
热议问题