{"id":13384,"date":"2020-05-13T14:48:22","date_gmt":"2020-05-13T14:48:22","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=13384"},"modified":"2021-11-08T10:10:30","modified_gmt":"2021-11-08T10:10:30","slug":"kubernetes-configmaps-how-to-update-configmap-automatically-into-pods","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/kubernetes-configmaps-how-to-update-configmap-automatically-into-pods\/","title":{"rendered":"Kubernetes configmaps: How to update configmap automatically into pods?"},"content":{"rendered":"\n<p>We often come acorss following questions while working with ConfigMap and secret are as follows;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>How to Updating Kubernetes Deployments on a ConfigMap Change?<\/li><li>How Mounted ConfigMap is updated automatically in pods?<\/li><li>While changing in configmap it doesn&#8217;t reflect automatically, every time I have to restart the pod. How can I do it automatically?<\/li><\/ul>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>To update a configmap or secret resource which depends on a deployment(pod). Obviously, updating them is not a big deal. But how would you notify to relevant deployment\/pod?<\/p>\n\n\n\n<p><strong>Method 1: Manual restart a pod\/deploy which would update volume with latest configmaps and secrets.<\/strong><\/p>\n\n\n\n<p>kubectl v1.15 now provides a rollout restart sub-command that allows you to restart Pods in a Deployment &#8211; taking into account your surge\/unavailability config &#8211; and thus have them pick up changes to a referenced ConfigMap, Secret or similar. It\u2019s worth noting that you can use this with clusters older than v1.15, as it\u2019s implemented in the client.<\/p>\n\n\n\n<p>Example usage: kubectl rollout restart deploy\/admission-control to restart a specific deployment. Easy as that!<\/p>\n\n\n\n<p>$ kubectl rollout restart deploy nginx -n dev<\/p>\n\n\n\n<p><strong>Method 2: Automatic how would you notify to relevant deployment\/pod on configmaps and secrets changes?<\/strong><\/p>\n\n\n\n<p>There are very good reference for this scnario are given below;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>https:\/\/medium.com\/@harik8\/kubectl-restart-po-deploy-a5b4c6d523fe<\/li><li>https:\/\/blog.questionable.services\/article\/kubernetes-deployments-configmap-change\/<\/li><\/ul>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_34446\"><iframe loading=\"lazy\"  id=\"_ytid_22265\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_34446\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>We often come acorss following questions while working with ConfigMap and secret are as follows; How to Updating Kubernetes Deployments on a ConfigMap Change? How Mounted ConfigMap is updated automatically&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4859],"tags":[],"class_list":["post-13384","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/13384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=13384"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/13384\/revisions"}],"predecessor-version":[{"id":24844,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/13384\/revisions\/24844"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=13384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=13384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=13384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}