Restart pods when configmap updates in Kubernetes?

后端 未结 7 2018
猫巷女王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:23

    Another way is to stick it into the command section of the Deployment:

    ...
    command: [ "echo", "
      option = value\n
      other_option = value\n
    " ]
    ...
    

    Alternatively, to make it more ConfigMap-like, use an additional Deployment that will just host that config in the command section and execute kubectl create on it while adding an unique 'version' to its name (like calculating a hash of the content) and modifying all the deployments that use that config:

    ...
    command: [ "/usr/sbin/kubectl-apply-config.sh", "
      option = value\n
      other_option = value\n
    " ]
    ...
    

    I'll probably post kubectl-apply-config.sh if it ends up working.

    (don't do that; it looks too bad)

    0 讨论(0)
提交回复
热议问题