{"id":38312,"date":"2019-10-31T22:22:55","date_gmt":"2019-10-31T19:22:55","guid":{"rendered":"https:\/\/prohoster.info\/blog\/prostoj-i-bezopasnyj-sposob-avtomatizatsii-kanareechnyh-deploev-s-pomoshhyu-helm\/"},"modified":"2019-10-31T22:22:55","modified_gmt":"2019-10-31T19:22:55","slug":"prostoj-i-bezopasnyj-sposob-avtomatizatsii-kanareechnyh-deploev-s-pomoshhyu-helm","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/prostoj-i-bezopasnyj-sposob-avtomatizatsii-kanareechnyh-deploev-s-pomoshhyu-helm","title":{"rendered":"A simple and safe way to automate canary deployments using Helm","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"A simple and safe way to automate canary deployments using Helm\" src=\"\/wp-content\/uploads\/2019\/09\/255c7f20fb17c079b8a59ced9c092088.jpeg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nCanary deployment is a highly effective method for testing new code on a subset of users. It significantly reduces the traffic load that may cause issues during deployment since it occurs only within a specific subgroup. This note is dedicated to how to organize such a deployment using Kubernetes and deployment automation. <i>It is assumed that you have some knowledge of Helm and Kubernetes resources.<\/i>. <br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n<img decoding=\"async\" alt=\"A simple and safe way to automate canary deployments using Helm\" src=\"\/wp-content\/uploads\/2019\/09\/e8501460ddbfe797d036a399680032c1.jpeg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nA simple canary deployment in Kubernetes consists of two key resources: the service itself and the deployment tool. The canary deployment operates through a single service that interacts with two different resources managing the updated traffic. One of these resources will run the 'canary' version, while the other will run the stable version. In this situation, we can regulate the number of canary versions to reduce the volume of traffic that needs to be managed. For example, if you prefer to use YAML, it would look like this in Kubernetes: <\/p>\n<pre><code class=\"xml\">kind: Deployment\nmetadata:\n  name: app-canary\n  labels:\n    app: app\nspec:\n  replicas: 1\n  ...\n    image: myapp:canary\n---\nkind: Deployment\nmetadata:\n  name: app\n  labels:\n    app: app\nspec:\n  replicas: 5\n  ...\n    image: myapp:stable\n---\nkind: Service\nselector:\n  app: app # Selector will route traffic to both deployments.<\/code><\/pre>\n<p>\nAn even simpler way to visualize this option is with kubectl, and in <noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/cluster-administration\/manage-deployment\/#canary-deployments\">the Kubernetes documentation<\/a><\/noindex> there is even a complete tutorial on this scenario. But the main question of this post is how we plan to automate this process using Helm. <\/p>\n<h3>Automating canary deployment <\/h3>\n<p>\nFirst of all, we will need a Helm chart map that already includes the resources discussed above. It should look something like this:<\/p>\n<pre><code class=\"xml\">~\\\/charts\\\/app\n\u251c\u2500\u2500 Chart.yaml\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 templates\n\u2502   \u251c\u2500\u2500 NOTES.txt\n\u2502   \u251c\u2500\u2500 _helpers.tpl\n\u2502   \u251c\u2500\u2500 deployment.yaml\n\u2502   \u2514\u2500\u2500 service.yaml\n\u2514\u2500\u2500 values.yaml<\/code><\/pre>\n<p>\nThe core concept of Helm is managing multi-version releases. The stable version is our main stable branch of the project's code. But with Helm, we can deploy a canary release with our experimental code. The key is to maintain traffic exchange between the stable version and the canary release. We will manage all of this using a special selector:<\/p>\n<pre><code class=\"xml\">selector:\n  app.kubernetes.io\\\/name: myapp<\/code><\/pre>\n<p>\nBoth our canary and stable deployment resources will mark this label on the modules. If everything is set up correctly, during the deployment of the canary version of our Helm chart, we will see that traffic will be directed to the freshly deployed modules. The stable version of this command will look like this: <\/p>\n<pre><code class=\"xml\">helm upgrade\n  --install myapp \n  --namespace default \n  --set app.name=myapp       # Goes into app.kubernetes.io\/name\n  --set app.version=v1       # Goes into app.kubernetes.io\/version\n  --set image.tag=stable \n  --set replicaCount=5<\/code><\/pre>\n<p>\nNow let's check our canary release. To deploy the canary version, we need to keep two things in mind. The release name must be different so we don't overwrite the current stable version. The version and tag must also differ so we can deploy different code and identify differences by resource labels. <\/p>\n<pre><code class=\"xml\">helm upgrade\n  --install myapp-canary \n  --namespace default \n  --set app.name=myapp       # Goes into app.kubernetes.io\/name\n  --set app.version=v2       # Goes into app.kubernetes.io\/version\n  --set image.tag=canary \n  --set replicaCount=1<\/code><\/pre>\n<p>\nThat's it! If you ping the service, you can see that the canary update routes traffic only part of the time. <\/p>\n<p>\nIf you're looking for deployment automation tools that include the logic described, take a look at <noindex><a rel=\"nofollow\" href=\"https:\/\/deliverybot.github.io\/\">Deliverybot<\/a><\/noindex> and on <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/deliverybot\/helm\">Helm automation tools on GitHub<\/a><\/noindex>. The Helm charts used to implement the method described above are available on GitHub, <noindex><a rel=\"nofollow\" href=\"http:\/\/github.com\/deliverybot\/helm\/charts\">here<\/a><\/noindex>. In general, this was a theoretical overview of how to implement canary version deployment automation in practice, with specific concepts and examples.<br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/itsumma\/blog\/468013\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041a\u0430\u043d\u0430\u0440\u0435\u0435\u0447\u043d\u044b\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041e\u043d \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0442\u0440\u0430\u0444\u0438\u043a-\u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u0433\u0440\u0443\u043f\u043f\u044b. \u042d\u0442\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u0435\u043f\u043b\u043e\u0439 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Kubernetes \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u043f\u043b\u043e\u044f. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u043a\u043e\u0435-\u0447\u0442\u043e \u0437\u043d\u0430\u0435\u0442\u0435 \u043e Helm \u0438 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":28760,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-38312","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041a\u0430\u043d\u0430\u0440\u0435\u0435\u0447\u043d\u044b\u0439.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/prostoj-i-bezopasnyj-sposob-avtomatizatsii-kanareechnyh-deploev-s-pomoshhyu-helm\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043d\u0430\u0440\u0435\u0435\u0447\u043d\u044b\u0445 \u0434\u0435\u043f\u043b\u043e\u0435\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Helm | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041a\u0430\u043d\u0430\u0440\u0435\u0435\u0447\u043d\u044b\u0439.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/prostoj-i-bezopasnyj-sposob-avtomatizatsii-kanareechnyh-deploev-s-pomoshhyu-helm\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T19:22:55+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T19:22:55+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47 A simple and secure way to automate canary deployments with Helm | ProHoster","description":"Canary.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/prostoj-i-bezopasnyj-sposob-avtomatizatsii-kanareechnyh-deploev-s-pomoshhyu-helm","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043d\u0430\u0440\u0435\u0435\u0447\u043d\u044b\u0445 \u0434\u0435\u043f\u043b\u043e\u0435\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Helm | ProHoster","og:description":"\u041a\u0430\u043d\u0430\u0440\u0435\u0435\u0447\u043d\u044b\u0439.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/prostoj-i-bezopasnyj-sposob-avtomatizatsii-kanareechnyh-deploev-s-pomoshhyu-helm","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T19:22:55+00:00","article:modified_time":"2019-10-31T19:22:55+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"38312","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-23 21:27:22","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 01:11:24","updated":"2026-01-23 21:27:22","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/38312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=38312"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/38312\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/28760"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=38312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=38312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=38312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}