{"id":64970,"date":"2022-06-09T09:00:33","date_gmt":"2022-06-09T09:00:33","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=64970"},"modified":"2022-06-09T09:00:33","modified_gmt":"2022-06-09T09:00:33","slug":"a-guide-to-container-orchestration-with-kubernetes","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=64970","title":{"rendered":"A guide to container orchestration with Kubernetes"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">A guide to container orchestration with Kubernetes<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/seth\" class=\"username\">Seth Kenlon<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Thu, 06\/09\/2022 &#8211; 03:00<\/span><\/p>\n<div data-drupal-selector=\"rate-node-70040\" class=\"rate-widget-thumbs-up\" title=\"Register or Login to like.\">\n<div class=\"rate-thumbs-up-btn-up vote-pending\"><a href=\"https:\/\/opensource.com\/user\/register\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml\">Login<\/a> to like<\/div>\n<div class=\"rate-score\"><a href=\"https:\/\/opensource.com\/user\/register\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml\">Login<\/a> to like<\/div>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>The term <i>orchestration<\/i> is relatively new to the IT industry, and it still has nuance that eludes or confuses people who don&#8217;t spend all day orchestrating. When I describe orchestration to someone, it usually sounds like I&#8217;m just describing automation. That&#8217;s not quite right. In fact, I wrote a whole article differentiating <a href=\"https:\/\/opensource.com\/article\/20\/11\/orchestration-vs-automation\">automation and orchestration<\/a>.<\/p>\n<p>An easy way to think about it is that orchestration is just a form of automation. To understand how you can benefit from orchestration, it helps to understand what specifically it automates.<\/p>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">More on Kubernetes<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/topics\/containers\/what-is-kubernetes?intcmp=7016000000127cYAAQ\">What is Kubernetes?<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/do080-deploying-containerized-applications-technical-overview?intcmp=7016000000127cYAAQ\">Free online course: Containers, Kubernetes and Red Hat OpenShift technical over\u2026<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/engage\/kubernetes-containers-storage-s-201911201051?intcmp=7016000000127cYAAQ\">eBook: Storage Patterns for Kubernetes<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/engage\/openshift-storage-testdrive-20170718?intcmp=7016000000127cYAAQ\">Test drive OpenShift hands-on<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/resources\/managing-containers-kubernetes-openshift-technology-detail?intcmp=7016000000127cYAAQ\">An introduction to enterprise Kubernetes<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/enterprisersproject.com\/article\/2017\/10\/how-explain-kubernetes-plain-english?intcmp=7016000000127cYAAQ\">How to explain Kubernetes in plain terms<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/kubernetes-raspberry-pi?intcmp=7016000000127cYAAQ\">eBook: Running Kubernetes on your Raspberry Pi homelab<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/kubernetes-cheat-sheet?intcmp=7016000000127cYAAQ\">Kubernetes cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/kubernetes-sysadmin?intcmp=7016000000127cYAAQ\">eBook: A guide to Kubernetes for SREs and sysadmins<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/kubernetes?intcmp=7016000000127cYAAQ\">Latest Kubernetes articles<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h2>Understanding containers<\/h2>\n<p>A container is an image of a file system containing only what&#8217;s required to run a specific task. Most people don&#8217;t build containers from scratch, although reading about <a href=\"https:\/\/opensource.com\/article\/22\/2\/build-your-own-container-linux-buildah\">how it&#8217;s done<\/a> can be elucidating. Instead, it&#8217;s more common to pull an existing image from a public container hub.<\/p>\n<p>A container engine is an application that runs a container. When a container is run, it&#8217;s launched with a kernel mechanism called a <code>cgroup<\/code>, which keeps processes within the container separate from processes running outside the container.<\/p>\n<h2>Run a container<\/h2>\n<p>You can run a container on your own Linux computer easily with <a href=\"https:\/\/opensource.com\/article\/18\/12\/podman-and-user-namespaces\">Podman<\/a>, <a href=\"https:\/\/opensource.com\/business\/14\/8\/docker-beginner-guide\">Docker<\/a>, or <a href=\"https:\/\/opensource.com\/article\/18\/11\/behind-scenes-linux-containers\">LXC<\/a>. They all use similar commands. I recommend Podman, as it&#8217;s daemonless, meaning a process doesn&#8217;t have to be running all the time for a container to launch. With Podman, your container engine runs only when necessary. Assuming you have a container engine installed, you can run a container just by referring to a container image you know to exist on a public container hub.<\/p>\n<p>For instance, to run an Nginx web server:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ podman run <span class=\"re5\">-p<\/span> <span class=\"nu0\">8080<\/span>:<span class=\"nu0\">80<\/span> nginx<br><span class=\"nu0\">10<\/span>-listen-on-ipv6-by-default.sh: info: Getting the checksum of <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>nginx<span class=\"sy0\">\/<\/span>conf.d<span class=\"sy0\">\/<\/span>default.conf<br><span class=\"nu0\">10<\/span>-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 <span class=\"kw1\">in<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>nginx<span class=\"sy0\">\/<\/span>conf.d<span class=\"sy0\">\/<\/span>default.conf<br><span class=\"br0\">[<\/span>...<span class=\"br0\">]<\/span><\/div><\/div><\/pre>\n<p>Open a separate terminal to test it using <a href=\"https:\/\/opensource.com\/article\/20\/5\/curl-cheat-sheet\" target=\"_blank\" rel=\"noopener\">curl<\/a>:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ curl <span class=\"re5\">--no-progress-meter<\/span> localhost:<span class=\"nu0\">8080<\/span> <span class=\"sy0\">|<\/span> html2text<br><span class=\"co0\"># Welcome to nginx!<\/span><br><br>\nIf you see this page, the nginx web server is successfully installed and<br>\nworking. Further configuration is required.<br><br>\nFor online documentation and support please refer to<br><span class=\"br0\">[<\/span>nginx.org<span class=\"br0\">]<\/span><span class=\"br0\">(<\/span>http:<span class=\"sy0\">\/\/<\/span>nginx.org<span class=\"sy0\">\/<\/span><span class=\"br0\">)<\/span>. \u00a0<br>\nCommercial support is available at <span class=\"br0\">[<\/span>nginx.com<span class=\"br0\">]<\/span><span class=\"br0\">(<\/span>http:<span class=\"sy0\">\/\/<\/span>nginx.com<span class=\"sy0\">\/<\/span><span class=\"br0\">)<\/span>.<br><br>\n_Thank you <span class=\"kw1\">for<\/span> using nginx._<\/div><\/div><\/pre>\n<p>As web server installs go, that&#8217;s pretty easy.<\/p>\n<p>Now imagine that the website you&#8217;ve just deployed gets an unexpected spike in traffic. You hadn&#8217;t planned for that, and even though Nginx is a very resilient web server, everything has its limits. With enough simultaneous traffic, even Nginx can crash. Now what?<\/p>\n<h2>Sustaining containers<\/h2>\n<p>Containers are cheap. In other words, as you&#8217;ve just experienced, they&#8217;re trivial to launch.<\/p>\n<p>You can use systemd to make a container resilient, too, so that a container automatically relaunches even in the event of a crash. This is where using Podman comes in handy. Podman has a command to generate a systemd service file based on an existing container:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ podman create <span class=\"re5\">--name<\/span> mynginx <span class=\"re5\">-p<\/span> <span class=\"nu0\">8080<\/span>:<span class=\"nu0\">80<\/span> nginx<br>\n$ podman generate systemd mynginx <br><span class=\"re5\">--restart-policy<\/span>=always <span class=\"re5\">-t<\/span> <span class=\"nu0\">5<\/span> <span class=\"re5\">-f<\/span> <span class=\"re5\">-n<\/span><\/div><\/div><\/pre>\n<p>You can launch your container service as a regular user:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">mkdir<\/span> <span class=\"re5\">-p<\/span> ~<span class=\"sy0\">\/<\/span>.config<span class=\"sy0\">\/<\/span>systemd<span class=\"sy0\">\/<\/span>user<br>\n$ <span class=\"kw2\">mv<\/span> .<span class=\"sy0\">\/<\/span>container-mynginx.service ~<span class=\"sy0\">\/<\/span>.config<span class=\"sy0\">\/<\/span>systemd<span class=\"sy0\">\/<\/span>user<span class=\"sy0\">\/<\/span><br>\n$ systemctl <span class=\"kw3\">enable<\/span> <span class=\"re5\">--now<\/span> <span class=\"re5\">--user<\/span> container-mynginx.service<br>\n$ curl <span class=\"re5\">--head<\/span> localhost:<span class=\"nu0\">8080<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">head<\/span> <span class=\"re5\">-n1<\/span><br>\nHTTP<span class=\"sy0\">\/<\/span><span class=\"nu0\">1.1<\/span> <span class=\"nu0\">200<\/span> OK<\/div><\/div><\/pre>\n<h2>Run pods of containers<\/h2>\n<p>Because containers are cheap, you can readily launch more than one container to meet the demand for your service. With two (or more) containers offering the same service, you increase the likelihood that better distribution of labor will successfully manage incoming requests.<\/p>\n<p>You can group containers together in pods, which Podman (as its name suggests) can create:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ systemctl stop <span class=\"re5\">--user<\/span> container-myngnix<br>\n$ podman run <span class=\"re5\">-dt<\/span> <span class=\"re5\">--pod<\/span> new:mypod <span class=\"re5\">-p<\/span> <span class=\"nu0\">8080<\/span>:<span class=\"nu0\">80<\/span> nginx<br>\n$ podman pod <span class=\"kw2\">ps<\/span><br>\nPOD ID \u00a0 \u00a0 NAME \u00a0 STATUS \u00a0CREATED \u00a0INFRA ID \u00a0<span class=\"co0\"># OF CONTAINERS<\/span><br>\n26424cc... mypod \u00a0Running 22m ago \u00a0e25b3... \u00a0 <span class=\"nu0\">2<\/span><\/div><\/div><\/pre>\n<p>This can also be automated using systemd:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ podman generate systemd mypod <br><span class=\"re5\">--restart-policy<\/span>=always <span class=\"re5\">-t<\/span> <span class=\"nu0\">5<\/span> <span class=\"re5\">-f<\/span> <span class=\"re5\">-n<\/span><\/div><\/div><\/pre>\n<h2>Clusters of pods and containers<\/h2>\n<p>It&#8217;s probably clear that containers offer diverse options for how you deploy networked applications and services, especially when you use the right tools to manage them. Both Podman and systemd integrate with containers very effectively, and they can help ensure that your containers are available when they&#8217;re needed.<\/p>\n<p>But you don&#8217;t really want to sit in front of your servers all day and all night just so you can manually add containers to pods any time the whole internet decides to pay you a visit. Even if you could do that, containers are only as robust as the computer they run on. Eventually, containers running on a single server do exhaust that server&#8217;s bandwidth and memory.<\/p>\n<p>The solution is a Kubernetes cluster: lots of servers, with one acting as a &#8220;control plane&#8221; where all configuration is entered and many, many others acting as compute nodes to ensure your containers have all the resources they need. Kubernetes is a big project, and there are many other projects, like <a href=\"https:\/\/opensource.com\/article\/20\/7\/terraform-kubernetes\">Terraform<\/a>, <a href=\"https:\/\/opensource.com\/article\/20\/3\/helm-kubernetes-charts\">Helm<\/a>, and <a href=\"https:\/\/opensource.com\/article\/22\/1\/learn-ansible\">Ansible<\/a>, that interface with Kubernetes to make common tasks scriptable and easy. It&#8217;s an important topic for all levels of systems administrators, architects, and developers.<\/p>\n<p>To learn all about container orchestration with Kubernetes, download our free eBook: <strong><a href=\"https:\/\/opensource.com\/downloads\/guide-orchestration-kubernetes\" target=\"_blank\" rel=\"noopener\">A guide to orchestration with Kubernetes<\/a><\/strong>.\u00a0The guide teaches you how to set up a local virtual cluster, deploy an application, set up a graphical interface, understand the YAML files used to configure Kubernetes, and more.<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>To learn all about container orchestration with Kubernetes, download our new eBook.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/kenlon-music-conducting-orchestra.png\" width=\"520\" height=\"292\" alt=\"CC-BY-SA William Kenlon  http:\/\/www.williamkenlon.com\" title=\"CC-BY-SA William Kenlon  http:\/\/www.williamkenlon.com\" loading=\"lazy\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>William Kenlon.\u00a0CC BY-SA 4.0<\/p>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/containers\" hreflang=\"en\">Containers<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/kubernetes\" hreflang=\"en\">Kubernetes<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-listicles field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/article\/22\/5\/containers-pods-101-ebook\" hreflang=\"en\">Experiment with containers and pods on your own computer<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/06\/cc-by-sa--11.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A guide to container orchestration with Kubernetes Seth Kenlon Thu, 06\/09\/2022 &#8211; 03:00 Register or Login to like Register or Login to like The term orchestration is relatively new to the IT industry, and it still has nuance that eludes or confuses people who don&#8217;t spend all day orchestrating. When I describe orchestration to someone, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":64971,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-64970","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/64970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64970"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/64970\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/64971"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}