<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Lab: Hands-on with Docker, Podman and Kubernetes on Example Academy</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/</link><description>Recent content in Lab: Hands-on with Docker, Podman and Kubernetes on Example Academy</description><generator>Hugo</generator><language>en</language><atom:link href="https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/index.xml" rel="self" type="application/rss+xml"/><item><title>Lab Overview</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/overview/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/overview/</guid><description>&lt;p>This lab provides practical experience installing Docker and Podman and setting up a Kubernetes cluster using kind. Once we have installed the container engine, we will understand the most commonly used container lifecycle operations and move on to build a container image using Dockerfile. We will uninstall Docker and install Podman to understand the Docker alternate tool. While there are many ways in which we can set up a Kubernetes cluster, we will use a simple method of setting up the cluster using kind.&lt;/p></description></item><item><title>Install Docker</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e1/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e1/</guid><description>&lt;p>In this exercise, we will install Docker and understand the most commonly used container lifecycle commands
and then build an image using Dockerfile.&lt;/p>
&lt;p>We can install Docker using the Docker’s apt repository, or install it manually, or use a convenient script
provided by Docker. For simplicity’s sake, we will use the below method.&lt;/p>
&lt;ol>
&lt;li>Install Docker:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>curl -fsSL https://get.docker.com/ | sh
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Enable Docker to start on boot:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo systemctl enable --now docker
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Check that the Docker service is running:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo systemctl status docker
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Add current user to the docker group:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo usermod -aG docker $USER
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Refresh shell session (by exiting &amp;amp; logging in again).&lt;/li>
&lt;li>Verify the Docker installation:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>docker ps
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Manage Container Lifecycle with Docker</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e2/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e2/</guid><description>&lt;ol>
&lt;li>Now that we have installed and verified Docker, let’s create our first container. This command pulls the hello-world image from Docker Hub and runs it as a container.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker container run hello-world
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Output:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>Unable to find image &lt;span style="color:#e6db74">&amp;#39;hello-world:latest&amp;#39;&lt;/span> locally
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>latest: Pulling from library/hello-world
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>c1ec31eb5944: Pull complete
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Digest:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sha256:ac69084025c660510933cca701f615283cdbb3aa0963188770b54c31c8962493
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Status: Downloaded newer image &lt;span style="color:#66d9ef">for&lt;/span> hello-world:latest
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Hello from Docker!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>This message shows that your installation appears to be working correctly.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>To generate this message, Docker took the following steps:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>1. The Docker client contacted the Docker daemon.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>2. The Docker daemon pulled the &lt;span style="color:#e6db74">&amp;#34;hello-world&amp;#34;&lt;/span> image from the Docker Hub.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">(&lt;/span>amd64&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>3. The Docker daemon created a new container from that image which runs the
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>executable that produces the output you are currently reading.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>4. The Docker daemon streamed that output to the Docker client, which sent
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>it
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>to your terminal.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>To try something more ambitious, you can run an Ubuntu container with:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ docker run -it ubuntu bash
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Share images, automate workflows, and more with a free Docker ID:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://hub.docker.com/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>For more examples and ideas, visit:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://docs.docker.com/get-started/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>List the container running on our host, by executing the following command:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker container ls
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Output:&lt;/p></description></item><item><title>Image Management with Docker</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e3/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e3/</guid><description>&lt;ol>
&lt;li>List the available images on our host. Notice when the images are not available on the host, they are by default downloaded from DockerHub.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker image ls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>REPOSITORY TAG IMAGE ID CREATED SIZE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ubuntu latest 174c8c134b2a &lt;span style="color:#ae81ff">3&lt;/span> weeks ago 77.9MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>nginx latest d453dd892d93 &lt;span style="color:#ae81ff">2&lt;/span> months ago 187MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>hello-world latest d2c94e258dcb &lt;span style="color:#ae81ff">8&lt;/span> months ago 13.3kB
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>If the image is already existing on the host, then creating a container is very quick. Let’s see how to pull an image from the registry:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker image pull alpine
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Using default tag: latest
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>latest: Pulling from library/alpine
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>661ff4d9561e: Pull complete
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Digest:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sha256:51b67269f354137895d43f3b3d810bfacd3945438e94dc5ac55fdac340352f48
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Status: Downloaded newer image &lt;span style="color:#66d9ef">for&lt;/span> alpine:latest
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>docker.io/library/alpine:latest
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>By default, the Daemon is configured to fetch the image from the Docker Hub registry and from the user account library, where Docker stores all the publicly available official images and fetches the image with tag as latest. We can override the default behavior by specifying what we want.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker image pull gcr.io/google-samples/hello-app:2.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>2.0: Pulling from google-samples/hello-app
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>07a64a71e011: Pull complete
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>fe5ca62666f0: Pull complete
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>b02a7525f878: Pull complete
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>1933f300df8c: Pull complete
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>36cc1f0ec872: Pull complete
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Digest:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sha256:7104356ed4e3476a96a23b96f8d7c04dfa7a1881aa97d66a76217f6bc8a370d0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Status: Downloaded newer image &lt;span style="color:#66d9ef">for&lt;/span> gcr.io/google-samples/hello-app:2.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>gcr.io/google-samples/hello-app:2.0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Let us build a simple image using Dockerfile. We will use the index.html file we created in an earlier step and copy it to our new image.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ cat &amp;gt; Dockerfile &lt;span style="color:#e6db74">&amp;lt;&amp;lt;EOF
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">&amp;gt; FROM nginx
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">&amp;gt; COPY . /usr/share/nginx/html
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">&amp;gt; EXPOSE 80/tcp
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">&amp;gt; CMD [&amp;#34;nginx&amp;#34;, &amp;#34;-g daemon off;&amp;#34;]
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">&amp;gt; EOF&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker image build . -t nginx:version1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">[&lt;/span>+&lt;span style="color:#f92672">]&lt;/span> Building 0.4s &lt;span style="color:#f92672">(&lt;/span>7/7&lt;span style="color:#f92672">)&lt;/span> FINISHED
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>docker:default
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">[&lt;/span>internal&lt;span style="color:#f92672">]&lt;/span> load .dockerignore
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.1s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">=&lt;/span>&amp;gt; transferring context: 2B
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.0s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">[&lt;/span>internal&lt;span style="color:#f92672">]&lt;/span> load build definition from Dockerfile
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.1s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">=&lt;/span>&amp;gt; transferring dockerfile: 123B
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.0s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">[&lt;/span>internal&lt;span style="color:#f92672">]&lt;/span> load metadata &lt;span style="color:#66d9ef">for&lt;/span> docker.io/library/nginx:latest
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.0s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">[&lt;/span>internal&lt;span style="color:#f92672">]&lt;/span> load build context
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.1s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">=&lt;/span>&amp;gt; transferring context: 5.74kB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.0s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">[&lt;/span>1/2&lt;span style="color:#f92672">]&lt;/span> FROM docker.io/library/nginx
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.1s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">[&lt;/span>2/2&lt;span style="color:#f92672">]&lt;/span> COPY . /usr/share/nginx/html
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.1s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; exporting to image
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.0s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">=&lt;/span>&amp;gt; exporting layers
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.0s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">=&lt;/span>&amp;gt; writing image
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sha256:69be93e604b157a2dda142b3444100e5e24013f2c29db16bd25c0c8de84c28b2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>0.0s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">=&lt;/span>&amp;gt; &lt;span style="color:#f92672">=&lt;/span>&amp;gt; naming to docker.io/library/nginx:version1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Create a container using the image we built and access the application.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker container run -dit --name webapp -p 8081:80
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>nginx:version1
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>8fd1b47bafda05c96faba7d46486ca90f4a828c221cb5fd689e819592b839c84
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ curl localhost:8081
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Welcome to Docker Training!!
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Clean up the unused images on the host by executing the following command:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo docker image prune -a
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>WARNING! This will remove all images without at least one container
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>associated to them.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Are you sure you want to &lt;span style="color:#66d9ef">continue&lt;/span>? &lt;span style="color:#f92672">[&lt;/span>y/N&lt;span style="color:#f92672">]&lt;/span> y
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Deleted Images:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>untagged: alpine:latest
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>untagged:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>alpine@sha256:51b67269f354137895d43f3b3d810bfacd3945438e94dc5ac55fdac340352f
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">48&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>deleted:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sha256:f8c20f8bbcb684055b4fea470fdd169c86e87786940b3262335b12ec3adef418
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>deleted:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sha256:5af4f8f59b764c64c6def53f52ada809fe38d528441d08d01c206dfb3fc3b691
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>untagged: gcr.io/google-samples/hello-app:2.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;Output truncated&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>There are additional image options; explore the sudo docker image &amp;ndash;help command and try
additional options.&lt;/li>
&lt;/ol></description></item><item><title>Uninstall Docker</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e4/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e4/</guid><description>&lt;ol>
&lt;li>Uninstall the Docker Engine, CLI, containerd, and Docker Compose packages:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo apt-get purge docker-ce docker-ce-cli containerd.io
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Reading package lists... Done
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Building dependency tree
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Reading state information... Done
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The following packages were automatically installed and are no longer
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>required:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>libatasmart4 libblockdev-fs2 libblockdev-loop2 libblockdev-part-err2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>libblockdev-part2 libblockdev-swap2 libblockdev-utils2 libblockdev2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>libmbim-glib4 libmbim-proxy libmm-glib0 libnspr4
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>libnss3 libnuma1 libparted-fs-resize0 libqmi-glib5 libqmi-proxy
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>libudisks2-0 libxmlb2 pigz slirp4netns usb-modeswitch usb-modeswitch-data
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Use &lt;span style="color:#e6db74">&amp;#39;sudo apt autoremove&amp;#39;&lt;/span> to remove them.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>The following packages will be REMOVED:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>containerd.io* docker-buildx-plugin* docker-ce* docker-ce-cli*
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>docker-ce-rootless-extras* docker-compose-plugin*
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">0&lt;/span> upgraded, &lt;span style="color:#ae81ff">0&lt;/span> newly installed, &lt;span style="color:#ae81ff">6&lt;/span> to remove and &lt;span style="color:#ae81ff">10&lt;/span> not upgraded.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>After this operation, &lt;span style="color:#ae81ff">410&lt;/span> MB disk space will be freed.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Do you want to &lt;span style="color:#66d9ef">continue&lt;/span>? &lt;span style="color:#f92672">[&lt;/span>Y/n&lt;span style="color:#f92672">]&lt;/span> y
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">(&lt;/span>Reading database ... &lt;span style="color:#ae81ff">62643&lt;/span> files and directories currently installed.&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Removing docker-ce-rootless-extras &lt;span style="color:#f92672">(&lt;/span>5:24.0.7-1~ubuntu.20.04~focal&lt;span style="color:#f92672">)&lt;/span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Removing docker-ce &lt;span style="color:#f92672">(&lt;/span>5:24.0.7-1~ubuntu.20.04~focal&lt;span style="color:#f92672">)&lt;/span> ...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;Output Trucncated&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Images, containers, volumes, or custom configuration files on your host aren&amp;rsquo;t automatically removed.
To delete all images, containers, and volumes, run:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo rm -rf /var/lib/docker
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo rm -rf /var/lib/containerd
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Installing Podman</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e5/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e5/</guid><description>&lt;ol>
&lt;li>Let’s &lt;a href="https://podman-desktop.io/downloads/">download&lt;/a> the latest Podman binaries and extract them to set up Podman on our host. Note: If you are running Ubuntu 20.10 or higher, you can simply use the package manager to install Podman.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ curl -fsSL -o podman-linux-amd64.tar.gz &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span>&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://github.com/mgoltzsche/podman-static/releases/latest/download/podmanlinux-amd64.tar.gz
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ tar -xf podman-linux-amd64.tar.gz
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo cp -r podman-linux-amd64/usr podman-linux-amd64/etc /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo ln -s /usr/bin/podman /usr/local/bin/podman
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Verify the Podman installation:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ podman --version
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>podman version 4.8.2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>To explore all the available options with Podman, execute:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ podman --help
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Usage:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>podman &lt;span style="color:#f92672">[&lt;/span>options&lt;span style="color:#f92672">]&lt;/span> &lt;span style="color:#f92672">[&lt;/span>command&lt;span style="color:#f92672">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Available Commands:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>attach Attach to a running container
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>auto-update Auto update containers according to their auto-update policy
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>build Build an image using instructions from Containerfiles
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>commit Create new image based on the changed container
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>compose Run compose workloads via an external provider such as
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>docker-compose or podman-compose
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>container Manage containers
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cp Copy files/folders between a container and the local
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>filesystem
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>create Create but &lt;span style="color:#66d9ef">do&lt;/span> not start a container
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>diff Display the changes to the object&lt;span style="color:#e6db74">&amp;#39;s file system
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">events Show podman system events
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">exec Run a process in a running container
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">export Export container&amp;#39;&lt;/span>s filesystem contents as a tar archive
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>generate Generate structured data based on containers, pods or volumes
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>healthcheck Manage health checks on containers
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>help Help about any command
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;Output Truncated&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>List the existing container, by executing the following command:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo podman container ps
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NAMES
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Create a container, by executing the following command:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo podman container run hello-world
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>✔ docker.io/library/hello-world:latest
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Trying to pull docker.io/library/hello-world:latest...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Getting image source signatures
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob c1ec31eb5944 &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying config d2c94e258d &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Writing manifest to image destination
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Hello from Docker!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>This message shows that your installation appears to be working correctly.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>To generate this message, Docker took the following steps:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>1. The Docker client contacted the Docker daemon.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>2. The Docker daemon pulled the &lt;span style="color:#e6db74">&amp;#34;hello-world&amp;#34;&lt;/span> image from the Docker Hub.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">(&lt;/span>amd64&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>3. The Docker daemon created a new container from that image which runs the
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>executable that produces the output you are currently reading.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>4. The Docker daemon streamed that output to the Docker client, which sent
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>it
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>to your terminal.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>To try something more ambitious, you can run an Ubuntu container with:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ docker run -it ubuntu bash
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Share images, automate workflows, and more with a free Docker ID:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https://hub.docker.com/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>We can list the available images on our host by executing the following command:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo podman image ls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>REPOSITORY TAG IMAGE ID CREATED SIZE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>docker.io/library/hello-world latest d2c94e258dcb &lt;span style="color:#ae81ff">8&lt;/span> months ago 26.3
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>kB
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>An Image can be built using Podman as well. We will use the same Dockerfile as in the earlier lab exercise.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>student@ubuntu:~$ sudo podman image build . -t nginx:podman
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>STEP 1/4: FROM nginx
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>✔ docker.io/library/nginx:latest
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Trying to pull docker.io/library/nginx:latest...
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Getting image source signatures
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob af107e978371 &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob 5e99d351b073 &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob 336ba1f05c3e &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob 8c37d2ff6efa &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob 51d6357098de &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob 782f1ecce57d &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying blob 7b73345df136 &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Copying config d453dd892d &lt;span style="color:#66d9ef">done&lt;/span> |
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Writing manifest to image destination
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>STEP 2/4: COPY . /usr/share/nginx/html
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>--&amp;gt; 95fa83a8887f
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>STEP 3/4: EXPOSE 80/tcp
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>--&amp;gt; aecf247e1625
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>STEP 4/4: CMD &lt;span style="color:#f92672">[&lt;/span>&lt;span style="color:#e6db74">&amp;#34;nginx&amp;#34;&lt;/span>, &lt;span style="color:#e6db74">&amp;#34;-g daemon off;&amp;#34;&lt;/span>&lt;span style="color:#f92672">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>COMMIT nginx:podman
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>--&amp;gt; 7958e43aed3c
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Successfully tagged localhost/nginx:podman
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>7958e43aed3c9591ca7ab5cae328dfdc8344a8a5420b07ac473bed169319869d
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Podman provides a command line interface (CLI) familiar to anyone who has used the Docker Container Engine. Most users can simply alias Docker to Podman (alias docker=podman) without any problems. Explore further options and commands using Podman.&lt;/li>
&lt;/ol></description></item><item><title>Setting up a Kubernetes Cluster with kind</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e6/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e6/</guid><description>&lt;p>&lt;a href="https://kind.sigs.k8s.io/">kind&lt;/a> is a tool for running local Kubernetes clusters using Docker container nodes. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI. We have uninstalled Docker in exercise 4; kind needs Docker as a prerequisite; let’s follow Exercise 4.1 steps and install Docker.
Note: Docker should be installed on the node before proceeding further.
To interact with our Kubernetes cluster, kubectl is the primary go to command line tool. Let us install kubectl on our node by executing these commands:&lt;/p></description></item><item><title>Deploy a Sample Application</title><link>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e7/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://layer5io.github.io/layer5-academy/pr-preview/pr-207/learning-paths/d011fd20-a3f5-4480-883b-dfb34321d168/cloud-container-and-infrastructure/introduction-to-containers-and-kubernetes/lab/e7/</guid><description>&lt;p>In this exercise, we will deploy a sample application in Kubernetes and access it.&lt;/p>
&lt;ol>
&lt;li>Create webapp.yaml file with contents below.
This file defines a Kubernetes deployment for your Sample Application.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">apiVersion&lt;/span>: &lt;span style="color:#ae81ff">apps/v1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">kind&lt;/span>: &lt;span style="color:#ae81ff">Deployment&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">metadata&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">name&lt;/span>: &lt;span style="color:#ae81ff">webapp&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">spec&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">replicas&lt;/span>: &lt;span style="color:#ae81ff">2&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">selector&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">matchLabels&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">app&lt;/span>: &lt;span style="color:#ae81ff">webapp&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">template&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">metadata&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">labels&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">app&lt;/span>: &lt;span style="color:#ae81ff">webapp&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">spec&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">containers&lt;/span>:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> - &lt;span style="color:#f92672">image&lt;/span>: &lt;span style="color:#ae81ff">nginx&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">name&lt;/span>: &lt;span style="color:#ae81ff">nginx&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Deploy the application:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kubectl apply -f webapp.yaml
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Verify the deployment:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kubectl get deployments
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NAME READY UP-TO-DATE AVAILABLE AGE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>webapp 2/2 &lt;span style="color:#ae81ff">2&lt;/span> &lt;span style="color:#ae81ff">2&lt;/span> 89s
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Set up port forwarding to access the application.
In this step, we are establishing a port forwarding rule that redirects network traffic from a specific port on your
local machine to the corresponding port on the Kubernetes pod hosting the server. By doing so, you enable
direct access to the server via &lt;a href="http://localhost:8080">http://localhost:8080&lt;/a> from your local computer. This action bridges the
network gap between your local environment and the isolated Kubernetes pod, allowing you to test and interact
with the deployed application as if it were running locally. It&amp;rsquo;s important to run this in a new terminal tab to
keep the port forwarding active throughout your testing session.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kubectl port-forward deploy/webapp 8080:80
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Forwarding from 127.0.0.1:8080 -&amp;gt; &lt;span style="color:#ae81ff">80&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Forwarding from &lt;span style="color:#f92672">[&lt;/span>::1&lt;span style="color:#f92672">]&lt;/span>:8080 -&amp;gt; &lt;span style="color:#ae81ff">80&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Test the sample application by sending an HTTP request.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>curl http://localhost:8080/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;!DOCTYPE html&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;html&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;head&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;title&amp;gt;Welcome to nginx!&amp;lt;/title&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;style&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>html &lt;span style="color:#f92672">{&lt;/span> color-scheme: light dark; &lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;lt;Output Truncated&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Cleanup by deleting the deployment:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kubectl delete deploy webapp
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item></channel></rss>