{"id":70831,"date":"2020-02-21T14:42:15","date_gmt":"2020-02-21T11:42:15","guid":{"rendered":"https:\/\/prohoster.info\/blog\/obnovlenie-kubernetes-klastera-bez-prostoya"},"modified":"2020-03-03T16:14:45","modified_gmt":"2020-03-03T13:14:45","slug":"obnovlenie-kubernetes-klastera-bez-prostoya","status":"publish","type":"post","link":"https:\/\/prohoster.info\/nl\/blog\/administrirovanie\/obnovlenie-kubernetes-klastera-bez-prostoya","title":{"rendered":"Kubernetes-clusterupdate zonder downtime","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"Kubernetes-clusterupdate zonder downtime\" src=\"\/wp-content\/uploads\/2020\/02\/53cdba726a58c16679c6443191f28321.png\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><em>Het updateproces voor uw Kubernetes-cluster<\/em><\/p>\n<p><\/p>\n<p>Op een gegeven moment bij het gebruik van een Kubernetes-cluster ontstaat de noodzaak om de actieve nodes bij te werken. Dit kan het bijwerken van pakketten, het bijwerken van de kernel of het implementeren van nieuwe afbeeldingen van virtuele machines omvatten. In Kubernetes-terminologie wordt dit <noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/disruptions\/#voluntary-and-involuntary-disruptions\">\"Vrijwillige Onderbreking\"<\/a><\/noindex>.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<p>Dit bericht maakt deel uit van een serie van 4 berichten:<\/p>\n<p><\/p>\n<ol>\n<li>Dit bericht.<\/li>\n<li>Correct afsluiten van pods in een Kubernetes-cluster<\/li>\n<li>Uitgestelde be\u00ebindiging van de pod tijdens het verwijderen<\/li>\n<li>Hoe downtime in een Kubernetes-cluster te vermijden met behulp van PodDisruptionBudgets<\/li>\n<\/ol>\n<p><\/p>\n<p><em>(opm. vert. vertalingen van de overige artikelen in de serie worden binnenkort verwacht)<\/em><\/p>\n<p><\/p>\n<p>In dit artikel beschrijven we alle hulpmiddelen die Kubernetes biedt om nul downtime te bereiken voor de nodes in uw cluster.<\/p>\n<p><\/p>\n<h2 id=\"opredelenie-problemy\">Probleemdefinitie<\/h2>\n<p><\/p>\n<p>In eerste instantie zullen we een na\u00efeve benadering volgen, waarbij we problemen identificeren en de potenti\u00eble risico's van deze aanpak evalueren, en we kennis opbouwen om elk van de problemen waarmee we tijdens de cyclus worden geconfronteerd op te lossen. Uiteindelijk zullen we een configuratie hebben die lifecycle hooks, readiness probes en Pod disruption budgets gebruikt om onze nul downtime te bereiken. <\/p>\n<p><\/p>\n<p>Om onze reis te beginnen, laten we een concreet voorbeeld nemen. Stel dat we een Kubernetes-cluster hebben met twee knooppunten, waarop een toepassing draait met twee pods, die zich achter bevinden <code>Service<\/code>:<\/p>\n<p>\n<img decoding=\"async\" alt=\"Kubernetes-clusterupdate zonder downtime\" src=\"\/wp-content\/uploads\/2020\/02\/f1eb999a0a088d7ed5b54c71e9b9ed1e.png\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><em>We beginnen met twee pods met Nginx en Service die draaien op onze twee nodes van het Kubernetes-cluster.<\/em><\/p>\n<p><\/p>\n<p>We willen de kernelversie van de twee werkende nodes in ons cluster bijwerken. Hoe doen we dat? Een eenvoudige oplossing zou zijn om nieuwe nodes met een bijgewerkte configuratie op te starten en vervolgens de oude nodes uit te schakelen, terwijl we tegelijkertijd de nieuwe nodes in gebruik nemen. Hoewel dit zou werken, zijn er enkele problemen met deze aanpak:<\/p>\n<p><\/p>\n<ul>\n<li>Wanneer u de oude nodes uitschakelt, worden ook de pods die daarop draaien uitgeschakeld. Wat als de pods moeten worden gewist voor een correcte uitschakeling? Het virtualisatiesysteem dat u gebruikt, wacht misschien niet op de afronding van het wisproces.<\/li>\n<li>Wat als u alle nodes tegelijkertijd uitschakelt? U krijgt aanzienlijke downtime terwijl de pods naar de nieuwe nodes verhuizen.<\/li>\n<\/ul>\n<p><\/p>\n<p>We need a way to correctly migrate pods from old nodes while ensuring that none of our workflows are running while we make changes to the node. Or when we perform a complete replacement of the cluster, as in the example (i.e., replacing VM images), we want to move the running applications from the old nodes to the new ones. In both cases, we want to prevent scheduling new pods on the old nodes and then evict all running pods from them. To achieve these goals, we can use the command <code>kubectl drain<\/code>.<\/p>\n<p><\/p>\n<h2 id=\"pereraspredelenie-vseh-podov-s-nody\">Redistributing all pods from the node<\/h2>\n<p><\/p>\n<p>The drain operation allows redistributing all pods from the node. During the execution of drain, the node is marked as unschedulable (flag <code>NoSchedule<\/code>). This prevents new pods from being scheduled on it. Then drain begins to evict pods from the node, terminating containers that are currently running on the node by sending a signal <code>TERM<\/code> to the containers in the pod.<\/p>\n<p><\/p>\n<p>Although <code>kubectl drain<\/code> it handles evicting pods well, there are still two factors that can cause the drain operation to fail:<\/p>\n<p><\/p>\n<ul>\n<li>Your application must be able to terminate gracefully upon receiving <code>TERM<\/code> the signal. When pods are evicted, Kubernetes sends a signal <code>TERM<\/code> to the containers and waits for them to stop for a specified amount of time, after which, if they haven't stopped, it terminates them forcefully. In any case, if your container does not respond to the signal correctly, you may still have issues stopping the pods if they are currently running (e.g., if a transaction is ongoing in the database).<\/li>\n<li>You lose all pods that contain your application. It may be unavailable when new containers are launched on the new nodes or, if your pods are deployed without controllers, they may not restart at all. <\/li>\n<\/ul>\n<p><\/p>\n<h2 id=\"izbegaem-prostoya\">Avoiding downtime<\/h2>\n<p><\/p>\n<p>To minimize downtime from voluntary disruption, such as from the drain operation for a node, Kubernetes provides the following failure handling options:<\/p>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/pod\/#termination-of-pods\">Graceful termination<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/containers\/container-lifecycle-hooks\/\">Lifecycle hooks<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/pods\/disruptions\/#how-disruption-budgets-work\">PodDisruptionBudgets<\/a><\/noindex><\/li>\n<\/ul>\n<p><\/p>\n<p>In the other parts of the cycle, we will use these Kubernetes functions to mitigate the impact of moving pods. To make it easier to follow the main idea, we will use our example above with the following resource configuration:<\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">---\napiVersion: apps\/v1\nkind: Deployment\nmetadata:\n name: nginx-deployment\n labels:\n   app: nginx\nspec:\n replicas: 2\n selector:\n   matchLabels:\n     app: nginx\n template:\n   metadata:\n     labels:\n       app: nginx\n   spec:\n     containers:\n     - name: nginx\n       image: nginx:1.15\n       ports:\n       - containerPort: 80\n---\nkind: Service\napiVersion: v1\nmetadata:\n name: nginx-service\nspec:\n selector:\n   app: nginx\n ports:\n - protocol: TCP\n   targetPort: 80\n   port: 80<\/code><\/pre>\n<p><\/p>\n<p>Deze configuratie is een minimaal voorbeeld <code>Deployment<\/code>, dat de nginx-pods in het cluster beheert. Daarnaast beschrijft de configuratie een bron <code>Service<\/code>, die kan worden gebruikt om toegang te krijgen tot de nginx-pods in het cluster.<\/p>\n<p><\/p>\n<p>Gedurende de hele cyclus zullen we deze configuratie iteratief uitbreiden, zodat deze uiteindelijk alle mogelijkheden van Kubernetes bevat voor minimale downtime.<\/p>\n<p><\/p>\n<p><em>Voor een volledig ge\u00efmplementeerde en getest versie van de updates van het Kubernetes-cluster voor zero downtime op AWS en andere bronnen, bezoek <noindex><a rel=\"nofollow\" href=\"https:\/\/gruntwork.io\/\">Gruntwork.io<\/a><\/noindex>.<\/em><\/p>\n<p><\/p>\n<h2 id=\"takzhe-chitayte-drugie-stati-v-nashem-bloge\">Lees ook andere artikelen op onze blog:<\/h2>\n<p><\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/nixys\/blog\/481932\/\">Zero Downtime Deployment en databases<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/nixys\/blog\/480072\/\">Kubernetes: waarom het zo belangrijk is om het resourcebeheer van het systeem in te stellen?<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/nixys\/blog\/481992\/\">Tekton Pipeline \u2014 Kubernetes-native pipelines<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/nixys\/blog\/473578\/\">Bouwen van dynamische modules voor Nginx<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/nixys\/blog\/473014\/\">Inleiding tot de Hashicorp Consul Kubernetes Autorisatie<\/a><\/noindex><\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/nixys\/blog\/468779\/\">Wat de migratie van ClickHouse zonder autorisatie naar ClickHouse met autorisatie heeft opgeleverd<\/a><\/noindex><\/li>\n<\/ul>\n<p>Bron: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/nixys\/blog\/489164\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e Kubernetes-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 Kubernetes \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043d\u043e\u0434. \u041e\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u044f\u0434\u0440\u0430 \u0438\u043b\u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d. \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Kubernetes \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f &quot;Voluntary Disruption&quot;. \u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0446\u0438\u043a\u043b\u0430 \u0438\u0437 4 \u043f\u043e\u0441\u0442\u043e\u0432: \u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442. \u041a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b pod\u2019\u043e\u0432 \u0432 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":70832,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-70831","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.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e.\" \/>\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\/nl\/blog\/administrirovanie\/obnovlenie-kubernetes-klastera-bez-prostoya\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"nl_NL\" \/>\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\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 Kubernetes-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0431\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u044f | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/nl\/blog\/administrirovanie\/obnovlenie-kubernetes-klastera-bez-prostoya\" \/>\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=\"2020-02-21T11:42:15+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-03-03T13:14:45+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\udd47Kubernetes-cluster zonder downtime bijwerken | ProHoster","description":"Het updateproces voor uw.","canonical_url":"https:\/\/prohoster.info\/nl\/blog\/administrirovanie\/obnovlenie-kubernetes-klastera-bez-prostoya","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"nl_NL","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\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 Kubernetes-\u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0431\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u044f | ProHoster","og:description":"\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e.","og:url":"https:\/\/prohoster.info\/nl\/blog\/administrirovanie\/obnovlenie-kubernetes-klastera-bez-prostoya","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":"2020-02-21T11:42:15+00:00","article:modified_time":"2020-03-03T13:14:45+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"70831","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":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 19:13:22","updated":"2022-09-29 13:06:50","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/posts\/70831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/comments?post=70831"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/posts\/70831\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/media\/70832"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/media?parent=70831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/categories?post=70831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/nl\/wp-json\/wp\/v2\/tags?post=70831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}