<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yusuf Isah</title>
    <description>The latest articles on DEV Community by Yusuf Isah (@yusbuntu).</description>
    <link>https://dev.to/yusbuntu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1883295%2F6736a016-ac59-4223-a3bf-22978cace9bf.png</url>
      <title>DEV Community: Yusuf Isah</title>
      <link>https://dev.to/yusbuntu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yusbuntu"/>
    <language>en</language>
    <item>
      <title>Chapter 5 - Kubernetes Labels and Annotations</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Fri, 06 Sep 2024 17:11:14 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-5-kubernetes-labels-and-annotations-564c</link>
      <guid>https://dev.to/yusbuntu/chapter-5-kubernetes-labels-and-annotations-564c</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In Kubernetes, labels and annotations are essential tools for managing and organizing resources. Labels provide a way to attach metadata to objects, which can be used for grouping, filtering, and selecting subsets of resources. Annotations, on the other hand, allow you to attach non-identifying metadata to objects, enabling you to store additional information that can be accessed by external tools or processes.&lt;/p&gt;

&lt;p&gt;In this chapter, we'll explore the concepts of labels and annotations, how to apply and modify them, and how they play a vital role in Kubernetes architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
Labels

&lt;ul&gt;
&lt;li&gt;Applying Labels&lt;/li&gt;
&lt;li&gt;Modifying Labels&lt;/li&gt;
&lt;li&gt;Label Selectors&lt;/li&gt;
&lt;li&gt;Label Selectors in API Objects&lt;/li&gt;
&lt;li&gt;Labels in Kubernetes Architecture&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Annotations&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Labels
&lt;/h2&gt;

&lt;p&gt;Labels are key-value pairs that are attached to Kubernetes objects, such as Pods, Nodes, Services, and Deployments. They are used to categorize and select subsets of objects based on criteria you define.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applying Labels
&lt;/h3&gt;

&lt;p&gt;In this section, we'll create two deployments (a way to create an array of Pods) and attach some labels to them. We’ll take two apps (called egypt and tanzania) and have one environment and one version for each.&lt;/p&gt;

&lt;p&gt;First, create the tanzania-staging deployment and set the &lt;code&gt;ver&lt;/code&gt;, &lt;code&gt;app&lt;/code&gt;, and &lt;code&gt;env&lt;/code&gt; labels:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;tanzania-staging.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata:
  name: tanzania-staging
  labels:
    app: tanzania
    &lt;span class="nb"&gt;env&lt;/span&gt;: staging
    ver: &lt;span class="s2"&gt;"1"&lt;/span&gt;
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tanzania
      &lt;span class="nb"&gt;env&lt;/span&gt;: staging
      ver: &lt;span class="s2"&gt;"1"&lt;/span&gt;
  template:
    metadata:
      labels:
        app: tanzania
        &lt;span class="nb"&gt;env&lt;/span&gt;: staging
        ver: &lt;span class="s2"&gt;"1"&lt;/span&gt;
    spec:
      containers:
      - name: tanzania-staging-container
        image: dockeryu853/greetings:tanzania
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, create the egypt-production deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;egypt-production.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata:
  name: egypt-production
  labels:
    app: egypt
    &lt;span class="nb"&gt;env&lt;/span&gt;: production
    ver: &lt;span class="s2"&gt;"2"&lt;/span&gt;
spec:
  replicas: 1
  selector:
    matchLabels:
      app: egypt
      &lt;span class="nb"&gt;env&lt;/span&gt;: production
      ver: &lt;span class="s2"&gt;"2"&lt;/span&gt;
  template:
    metadata:
      labels:
        app: egypt
        &lt;span class="nb"&gt;env&lt;/span&gt;: production
        ver: &lt;span class="s2"&gt;"2"&lt;/span&gt;
    spec:
      containers:
      - name: egypt-production-container
        image: dockeryu853/greetings:egypt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After applying both manifests, you should have two deployments in your Kubernetes cluster - &lt;strong&gt;tanzania-staging&lt;/strong&gt; and &lt;strong&gt;egypt-production&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44hf9obzg2k3jxo4nxyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44hf9obzg2k3jxo4nxyn.png" alt="Image description" width="503" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see the labels associated with your deployments, simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get deployment &lt;span class="nt"&gt;--show-labels&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ljfi6bhnwzvcbwtpam3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ljfi6bhnwzvcbwtpam3.png" alt="Image description" width="721" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Modifying Labels
&lt;/h3&gt;

&lt;p&gt;Labels can be modified using the &lt;code&gt;kubectl label&lt;/code&gt; command. Here's how you can add or update a label on an existing object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl label deployment tanzania-staging &lt;span class="nb"&gt;env&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--overwrite&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command updates the environment label on the &lt;code&gt;tanzania-staging&lt;/code&gt; deployment to test.&lt;/p&gt;

&lt;p&gt;You can confirm this update by running the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get deployment &lt;span class="nt"&gt;--show-labels&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ahhi7wnuv73f47pvv4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ahhi7wnuv73f47pvv4l.png" alt="Image description" width="713" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Label Selectors
&lt;/h3&gt;

&lt;p&gt;Label selectors allow you to filter and select resources based on their labels. They are commonly used in Kubernetes to specify which objects should be targeted by a particular operation.&lt;/p&gt;

&lt;p&gt;For example, to list all deployments with the label app=egypt, you can use the &lt;code&gt;kubectl get&lt;/code&gt; command with the &lt;code&gt;-l&lt;/code&gt; option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get deployment &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;egypt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the &lt;code&gt;--selector&lt;/code&gt; flag to list which resources have a particular label in your Kubernetes cluster. For example, if you want to list only deployments that have the ver label set to 2, you can simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get deployment &lt;span class="nt"&gt;--selector&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ver=2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Label Selectors in API Objects
&lt;/h3&gt;

&lt;p&gt;Label selectors are also used in API objects like Services, ReplicaSets, and Deployments to define which Pods they should manage. For example, in the egypt-production.yaml manifest we created, the &lt;code&gt;selector&lt;/code&gt; field uses label selectors to target Pods with the &lt;code&gt;app=egypt&lt;/code&gt; label.&lt;/p&gt;

&lt;h3&gt;
  
  
  Labels in Kubernetes Architecture
&lt;/h3&gt;

&lt;p&gt;Labels are integral to the Kubernetes architecture. They are used by the system to determine how to manage resources, such as deciding which Nodes a Pod should run on, or which Pods should receive traffic from a Service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Annotations
&lt;/h2&gt;

&lt;p&gt;Annotations are another form of metadata that can be attached to Kubernetes objects. Unlike labels, annotations are not used for selection or grouping. Instead, they are used to store non-identifying information that might be needed by tools or processes.&lt;/p&gt;

&lt;p&gt;Annotations are key-value pairs, just like labels, but their purpose is different. Here’s an example of applying annotations to a Pod:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apiVersion: v1
kind: Pod
metadata:
  name: my-pod
  annotations:
    information: &lt;span class="s2"&gt;"This is my first pod"&lt;/span&gt;
    group: &lt;span class="s2"&gt;"devops"&lt;/span&gt;
spec:
  containers:
    - name: my-container
      image: nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the Pod has two annotations: &lt;code&gt;information&lt;/code&gt; and &lt;code&gt;group&lt;/code&gt;. These annotations provide additional context about the Pod but are not used for selection or filtering.&lt;/p&gt;

&lt;p&gt;Annotations are commonly used to store information such as build details, release versions, or URLs for documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this chapter, we explored the power of labels and annotations in Kubernetes. By understanding how to apply, modify, and utilize these metadata mechanisms, you'll be able to effectively organize and manage your Kubernetes resources. Stay tuned for the next chapter in our Kubernetes series!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Kubernetes!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>labels</category>
    </item>
    <item>
      <title>Chapter 5 - Building Docker Images</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Fri, 06 Sep 2024 16:22:13 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-5-building-docker-images-36ao</link>
      <guid>https://dev.to/yusbuntu/chapter-5-building-docker-images-36ao</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;To truly harness the power of Docker, we need to create our own custom images. This chapter will take you into the world of image creation, covering the essential topics of building images from Dockerfiles, tagging images for easy management, and utilizing multi-stage builds for efficient development. Whether you're building a simple web application or a complex microservices architecture, understanding how to build Docker images is a crucial step in unlocking the full potential of containerization.&lt;/p&gt;

&lt;p&gt;In this chapter, we will be containerizing a simple Go application called "greetings-app". All the files and directories you need to follow along with this tutorial can be found on my GitHub repository. Simply log into your GitHub repository and search for either "yusbuntu/greetings-tanzania" or "yusbuntu/greetings-egypt". Copy the URL of whichever one you choose and clone the repository on your local machine using the "git clone [url_of_repository_you_want_to_clone]" command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Building Images From a Dockerfile&lt;/li&gt;
&lt;li&gt;Tagging Images&lt;/li&gt;
&lt;li&gt;Multi-stage Builds&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Building Images From a Dockerfile
&lt;/h2&gt;

&lt;p&gt;After navigating into the &lt;code&gt;project&lt;/code&gt; directory of the repository you just cloned, you should see the files and directory below after running the &lt;code&gt;ls&lt;/code&gt; command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89oi658auokjqlewfii5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F89oi658auokjqlewfii5.png" alt="Image description" width="548" height="38"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;greetings-app&lt;/code&gt; which is colorized green, is the Go executable that is created after building the application. You can run this executable by simply typing on your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./greetings-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, go to your browser and type &lt;code&gt;localhost:8080/&lt;/code&gt; to see the application in its full glory :). To terminate the application, hold the &lt;code&gt;ctrl&lt;/code&gt; button and press the &lt;code&gt;c&lt;/code&gt; button on your keyboard. Now that you have seen what the greetings-app looks like, let's build a Docker image of this application using a Dockerfile. But first, let's take a look at the contents of our Dockerfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano Dockerfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9fu6kd7gpu6vhepbtxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9fu6kd7gpu6vhepbtxp.png" alt="Image description" width="411" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In summary, this Dockerfile is building a Docker image for a Go application named greetings-app that listens on port 8080. The image is built using the official Golang 1.18 image as the base, and the resulting image contains the compiled Go binary and exposes the necessary port.&lt;/p&gt;

&lt;p&gt;To build the Docker image, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; greetings-app &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-t&lt;/code&gt; flag tags the image with a name (greetings-app), and the &lt;code&gt;.&lt;/code&gt; at the end specifies the build context, typically the current directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tagging Images
&lt;/h2&gt;

&lt;p&gt;Tagging images is a crucial part of managing and deploying Docker images. Tags help you identify different versions of your images. To add a tag to an image, you can use the &lt;code&gt;docker tag&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker tag greetings-app greetings-app:v1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command tags the &lt;code&gt;greetings-app&lt;/code&gt; image with the version &lt;code&gt;v1.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally, let's start a container using the image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 greetings-app:v1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the command above, the&lt;code&gt;-d&lt;/code&gt; flag runs the container in detached or daemon mode. The &lt;code&gt;-p&lt;/code&gt; flag exposes port 8080 on the container to port 8080 on the host machine. When you run &lt;code&gt;docker ps&lt;/code&gt;, you should see your container running. To stop the container, use the &lt;code&gt;docker stop [container_ID]&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;You can also pass environment variables to the greetings-app container. To do this, use the &lt;code&gt;-e&lt;/code&gt; flag. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;GREETING&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Hello Docker Champ!"&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 greetings-app:v1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Multi-stage Builds
&lt;/h2&gt;

&lt;p&gt;Multi-stage builds are an advanced feature in Docker that allow you to use multiple "FROM" statements in your Dockerfile. This helps in reducing the final image size by copying only the necessary files from intermediate/temporary stages. The image we created earlier is about 984MB in size. This is not ideal for production due to the reasons below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slower Deployment:&lt;/strong&gt; Larger images take longer to download and deploy, which means slower startup times for your application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Increased Storage:&lt;/strong&gt; Larger images consume more storage space on your servers, which can lead to increased costs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security Risks:&lt;/strong&gt; Larger images may contain unnecessary packages or dependencies, increasing the attack surface for potential security vulnerabilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Resource Intensive:&lt;/strong&gt; Larger images typically require more resources (CPU, memory) to run, which can impact performance and scalability.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To solve these problems, let's re-build the Docker image for our greetings app using a multi-stage build. The Dockerfile we will use to achieve this is titled &lt;code&gt;Dockerfile.multi&lt;/code&gt; in the &lt;code&gt;project&lt;/code&gt; directory. Before building the Docker image, let's take a look at its contents:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7falr6ulb82rnybxhagh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7falr6ulb82rnybxhagh.png" alt="Image description" width="800" height="597"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The goal of this multi-stage build is to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use the Golang image to build the application, taking advantage of its build tools and dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a smaller, more light-weight Debian image for the final stage, which will run the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep the final image size small by only copying the necessary files from the Build Stage.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach allows for efficient and optimized image creation, reducing the final image size and improving deployment times.&lt;/p&gt;

&lt;p&gt;To build the Docker image from this Dockerfile, simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; greetings-app:v2.0 &lt;span class="nt"&gt;-f&lt;/span&gt; Dockerfile.multi &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets breakdown the components of the command above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker build&lt;/code&gt;: This is the command to build a Docker image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-t greetings-app:v2.0&lt;/code&gt;: This option tags the image with the name &lt;code&gt;greetings-app&lt;/code&gt; and version &lt;code&gt;v2.0&lt;/code&gt;. This makes it easy to identify and reference the image later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-f Dockerfile.multi&lt;/code&gt;: This option specifies the Dockerfile to use for the build. In this case, it's &lt;code&gt;Dockerfile.multi&lt;/code&gt; instead of the default &lt;code&gt;Dockerfile&lt;/code&gt;. This allows you to have multiple Dockerfiles for different build scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.&lt;/code&gt;: This is the context directory for the build. The &lt;code&gt;.&lt;/code&gt; refers to the current directory, which means Docker will look for the Dockerfile.multi file in the current directory and use the files in the current directory as the build context.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After building the image, If you run &lt;code&gt;docker images&lt;/code&gt; you will notice that this new image is only about 78.8MB in size. That is a massive size difference compared to the 984MB size of the previous image.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;As an exercise, start a container using this new image&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this chapter, we explored the fundamentals of building Docker images from Dockerfiles, and tagging them for versioning. We also highlighted the importance of a small image size, and utilized multi-stage builds for efficient image creation. Through consistent practice, you'll become proficient in creating high-quality Docker images that meet the unique needs of your applications.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Docker!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockerfiles</category>
      <category>multistage</category>
    </item>
    <item>
      <title>Chapter 5 - Cloning a Remote Repository</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Thu, 05 Sep 2024 17:28:12 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-5-cloning-a-remote-repository-mi1</link>
      <guid>https://dev.to/yusbuntu/chapter-5-cloning-a-remote-repository-mi1</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Cloning a remote repository is an important Git operation that allows you to create a local copy of a repository hosted on a remote server, such as GitHub, GitLab, or Bitbucket. In this chapter, we'll explore the steps for cloning a remote repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
What is Cloning?

&lt;ul&gt;
&lt;li&gt;Why Clone a Repository?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;How to Clone a Remote Repository&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Cloning?
&lt;/h2&gt;

&lt;p&gt;Cloning a repository creates a new local repository that is an exact copy of the remote repository. This includes all files, commits, and branches. Cloning is a one-time operation that creates a permanent connection between your local repository and the remote repository. This connection allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pull changes from the remote repository to your local copy using &lt;code&gt;git pull&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send your local changes to the remote repository using &lt;code&gt;git push&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep track of branches between your local and remote repositories.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why Clone a Repository?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaboration:&lt;/strong&gt; Cloning repositories allows you to contribute to open-source projects or collaborate with others.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Backup:&lt;/strong&gt; You can clone your repository to create a backup of your project.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Clone a Remote Repository
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Get the Repository URL&lt;/em&gt;: Go to Github and search for any project of your choice. Click on the &lt;code&gt;code&lt;/code&gt; button and then copy the URL of the repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Open Terminal or Command Prompt:&lt;/em&gt; Open a terminal or command prompt on your local machine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Use the Git Clone Command:&lt;/em&gt; Run the command &lt;code&gt;git clone&lt;/code&gt;; e.g.,&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git clone https://github.com/kubernetes/kubernetes.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Once you clone a project and you navigate into it using the &lt;code&gt;cd&lt;/code&gt; command, you can use &lt;code&gt;git log&lt;/code&gt; to see the previous commits associated with the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, cloning a remote repository is a fundamental skill for any developer, enabling seamless collaboration and version control. By mastering the art of cloning, you can effortlessly create local copies of remote repositories, track changes, and contribute to projects with ease. With this guide, you're now equipped to clone confidently.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to comment and share this article. Please follow my blog for more insights on Git and Github!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Chapter 5 - TCP/IP Protocol Suite</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Thu, 05 Sep 2024 17:08:15 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-5-tcpip-protocol-suite-577g</link>
      <guid>https://dev.to/yusbuntu/chapter-5-tcpip-protocol-suite-577g</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The TCP/IP protocol suite is the foundation of Internet and network communication. It defines how data is transmitted over networks and ensures reliable and secure communication between devices. This chapter covers the common protocols within the TCP/IP suite. We'll also delve into port numbers, including well-known port numbers and their associated services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
Common Protocols

&lt;ul&gt;
&lt;li&gt;TCP&lt;/li&gt;
&lt;li&gt;UDP&lt;/li&gt;
&lt;li&gt;IP&lt;/li&gt;
&lt;li&gt;ICMP&lt;/li&gt;
&lt;li&gt;ARP&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Port Numbers

&lt;ul&gt;
&lt;li&gt;Well-known port numbers and their services&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Protocols
&lt;/h2&gt;

&lt;h3&gt;
  
  
  TCP
&lt;/h3&gt;

&lt;p&gt;TCP (Transmission Control Protocol) is a connection-oriented protocol that ensures reliable data transmission between devices. It establishes a connection before transmitting data, checks for errors, and guarantees the delivery of data in the correct order.&lt;/p&gt;

&lt;h3&gt;
  
  
  UDP
&lt;/h3&gt;

&lt;p&gt;UDP (User Datagram Protocol) is a connectionless protocol that offers fast but unreliable data transmission. It is used for applications where speed is crucial and error correction is not necessary, such as video streaming and online gaming.&lt;/p&gt;

&lt;h3&gt;
  
  
  IP
&lt;/h3&gt;

&lt;p&gt;IP (Internet Protocol) is responsible for addressing and routing packets of data so they can travel across networks and arrive at the correct destination. IP addresses uniquely identify devices on a network.&lt;/p&gt;

&lt;h3&gt;
  
  
  ICMP
&lt;/h3&gt;

&lt;p&gt;ICMP (Internet Control Message Protocol) is used for error reporting and network diagnostics. It sends messages about network issues back to the sender, such as unreachable destinations or packet loss.&lt;/p&gt;

&lt;h3&gt;
  
  
  ARP
&lt;/h3&gt;

&lt;p&gt;ARP (Address Resolution Protocol) is used to map IP addresses to physical MAC addresses in a local network. This allows devices to communicate within the same local network segment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Port Numbers
&lt;/h2&gt;

&lt;p&gt;Port numbers are used to identify specific services and applications on a device. They facilitate communication between devices by ensuring that data is sent to the correct application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Well-known port numbers and their services
&lt;/h3&gt;

&lt;p&gt;Port numbers are assigned by the Internet Assigned Numbers Authority (IANA) for use by standard network services. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;HTTP (Port 80)&lt;/strong&gt;: The default port for the &lt;code&gt;Hypertext Transfer Protocol&lt;/code&gt;, used for web traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;HTTPS (Port 443)&lt;/strong&gt;: The default port for secure web traffic using the &lt;code&gt;Hypertext Transfer Protocol Secure&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SSH (Port 22)&lt;/strong&gt;: The default port for &lt;code&gt;Secure Shell&lt;/code&gt;, used for secure remote access to devices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;FTP (Port 21)&lt;/strong&gt;: The default port for the &lt;code&gt;File Transfer Protocol&lt;/code&gt;, used for transferring files between devices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SMTP (Port 25)&lt;/strong&gt;: The default port for the &lt;code&gt;Simple Mail Transfer Protocol&lt;/code&gt;, used for sending emails.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DNS (Port 53)&lt;/strong&gt;: The default port for the &lt;code&gt;Domain Name System&lt;/code&gt;, used for resolving domain names to IP addresses.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding the TCP/IP protocol suite and port numbers is essential for managing and troubleshooting network communication. These protocols ensure reliable and efficient data transmission, while port numbers help direct data to the correct application or service.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Networking!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>tcpip</category>
      <category>networking</category>
      <category>http</category>
    </item>
    <item>
      <title>Chapter 5 - Linux File Permissions and Ownership</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Thu, 05 Sep 2024 16:40:31 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-5-linux-file-permissions-and-ownership-172g</link>
      <guid>https://dev.to/yusbuntu/chapter-5-linux-file-permissions-and-ownership-172g</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In Linux, permissions and ownership play a crucial role in controlling access to files and directories. Understanding permissions and ownership is essential for maintaining security and organization in your Linux system. In this chapter, we'll delve into the world of permissions and ownership, exploring how to understand, change, and manage them effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Understanding Permissions&lt;/li&gt;
&lt;li&gt;
Changing Permissions

&lt;ul&gt;
&lt;li&gt;
chmod: Change File Modes

&lt;ul&gt;
&lt;li&gt;Using Symbolic Representation&lt;/li&gt;
&lt;li&gt;Using Octal Values&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;

Changing Ownership

&lt;ul&gt;
&lt;li&gt;chown: Change File Owner and Group&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Understanding Permissions
&lt;/h2&gt;

&lt;p&gt;Linux permissions determine what actions users can perform on files and directories. There are three primary permissions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Read (r)&lt;/strong&gt;: This allows users to view file contents or list directory contents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Write (w)&lt;/strong&gt;: This enables users to modify file contents or create/delete files in a directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Execute (x)&lt;/strong&gt;: This allows users to execute files (e.g., run programs) or access directories.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These permissions are assigned to three types of users:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Owner&lt;/strong&gt;: This is the user who created the file or directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Group&lt;/strong&gt;: This refers to a group of users with shared permissions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Other&lt;/strong&gt; This refers to all other users on the system.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Permissions can also be represented using octal values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;r&lt;/strong&gt; = 4&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;w&lt;/strong&gt; = 2&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;x&lt;/strong&gt; = 1&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To see the permissions for the files and folders in your current working directory, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, a file permission of &lt;code&gt;rwxr-xr--&lt;/code&gt; translates to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Owner&lt;/strong&gt;: read, write, execute (rwx)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Group&lt;/strong&gt;: read, execute (r-x)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Others&lt;/strong&gt;: read (r--)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Changing Permissions
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;chmod&lt;/code&gt; command is used to change the permissions of a file or directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  chmod: Change File Modes
&lt;/h3&gt;

&lt;p&gt;To change permissions using &lt;code&gt;chmod&lt;/code&gt;, you can use either symbolic representation or octal values.&lt;/p&gt;

&lt;h4&gt;
  
  
  Using Symbolic Representation
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;For example, to add execute permission for the owner, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;u+x filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To remove write permission for the group, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;g-w filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To set read and execute permissions for others, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;&lt;span class="nv"&gt;o&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rx filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Using Octal Values
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Set permissions to &lt;code&gt;rwxr-xr-x&lt;/code&gt; (755)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;755 filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;rwxr-xr-x&lt;/code&gt; above can be broken down into three parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;rwx&lt;/strong&gt; (owner permissions)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;r-x&lt;/strong&gt; (group permissions)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;r-x&lt;/strong&gt; (others permissions)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each part can be converted to a numerical value using the following mapping:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;r&lt;/strong&gt; (read) = 4&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;w&lt;/strong&gt; (write) = 2&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;x&lt;/strong&gt; (execute) = 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;-&lt;/strong&gt; (no permission) = 0&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, let's convert each part:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;rwx&lt;/strong&gt; (owner) = 4 + 2 + 1 = 7&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;r-x&lt;/strong&gt; (group) = 4 + 0 + 1 = 5&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;r-x&lt;/strong&gt; (others) = 4 + 0 + 1 = 5&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, combine the three numerical values into a single octal number: &lt;code&gt;755&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set permissions to &lt;code&gt;rw-r--r--&lt;/code&gt; (644):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;chmod &lt;/span&gt;644 filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Changing Ownership
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;chown&lt;/code&gt; command is used to change the ownership of a file or directory. Ownership can be assigned to a user and a group.&lt;/p&gt;

&lt;h3&gt;
  
  
  chown: Change File Owner and Group
&lt;/h3&gt;

&lt;p&gt;To change the owner and group of a file or directory, use the following syntax:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the owner of a file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    &lt;span class="nb"&gt;chown &lt;/span&gt;username filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Change the owner and group of a file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;chown &lt;/span&gt;username:groupname filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Change the group of a file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;chown&lt;/span&gt; :groupname filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the owner to &lt;code&gt;Mike&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo chown &lt;/span&gt;Mike file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Change the owner to &lt;code&gt;alice&lt;/code&gt; and the group to &lt;code&gt;developers&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo chown &lt;/span&gt;alice:developers file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding and managing permissions and ownership in Linux is essential for controlling access to files and directories. By using commands like &lt;code&gt;chmod&lt;/code&gt; and &lt;code&gt;chown&lt;/code&gt;, you can ensure that your system's security and access controls are properly maintained.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Linux!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>chmod</category>
      <category>chown</category>
      <category>linuxpermissions</category>
    </item>
    <item>
      <title>Chapter 4 - Kubernetes Pods</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Tue, 27 Aug 2024 14:34:01 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-4-kubernetes-pods-3hhi</link>
      <guid>https://dev.to/yusbuntu/chapter-4-kubernetes-pods-3hhi</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In Kubernetes, the smallest and simplest unit of deployment is a Pod. Pods represent a single instance of a running process in your cluster. They encapsulate one or more containers, their storage resources, a unique network IP, and options that govern how the containers should run. This chapter will explore the concept of Pods, how to create and manage them, and how to ensure their health and performance in a Kubernetes cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
Pods in Kubernetes

&lt;ul&gt;
&lt;li&gt;Key Points About Pods&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

The Pod Manifest

&lt;ul&gt;
&lt;li&gt;Creating a Pod&lt;/li&gt;
&lt;li&gt;Creating a Pod Manifest&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Running Pods

&lt;ul&gt;
&lt;li&gt;Listing Pods&lt;/li&gt;
&lt;li&gt;Pod Details&lt;/li&gt;
&lt;li&gt;Deleting a Pod&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Accessing Your Pod

&lt;ul&gt;
&lt;li&gt;Getting More Information with Logs&lt;/li&gt;
&lt;li&gt;Running Commands in Your Containers with exec&lt;/li&gt;
&lt;li&gt;Copying Files to and From Containers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Health Checks

&lt;ul&gt;
&lt;li&gt;Liveness Probe&lt;/li&gt;
&lt;li&gt;Readiness Probe&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Resource Management

&lt;ul&gt;
&lt;li&gt;Resource Requests: Minimum Required Resources&lt;/li&gt;
&lt;li&gt;Capping Resource Usage With Limits&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Persisting Data with Volumes

&lt;ul&gt;
&lt;li&gt;Using Volumes with Pods&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Putting it all Together&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pods in Kubernetes
&lt;/h2&gt;

&lt;p&gt;In Kubernetes, a Pod is the basic execution unit that comprises one or more containers. The term, &lt;strong&gt;Pod&lt;/strong&gt;, is a nod to the Docker whale theme, as it refers to a group of whales swimming together. Similarly, a Pod groups containers together to work as a single, cohesive unit that can share resources and dependencies, communicate with each other, and be co-scheduled.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Points About Pods:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Single Unit of Deployment&lt;/strong&gt;: Pods are the smallest deployable units in Kubernetes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Shared Context&lt;/strong&gt;: Containers within a Pod share the same network namespace, Inter-Process Communication (IPC) namespace, and can share storage volumes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lifecycle&lt;/strong&gt;: Pods are created, scheduled, and managed by the Kubernetes control plane.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Pod Manifest
&lt;/h2&gt;

&lt;p&gt;A Pod manifest is a YAML file that defines the desired configuration of a Pod, utilizing Kubernetes' declarative approach. This means you specify the ideal state of your Pod in the manifest file, and then Kubernetes works to ensure that the actual state matches your declared intentions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Pod
&lt;/h3&gt;

&lt;p&gt;You can create a Pod by defining a manifest in YAML and applying it to your Kubernetes cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Pod Manifest
&lt;/h3&gt;

&lt;p&gt;To create a Pod manifest:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Define the &lt;code&gt;apiVersion&lt;/code&gt;, &lt;code&gt;kind&lt;/code&gt;, and &lt;code&gt;metadata sections&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under &lt;code&gt;spec&lt;/code&gt;, specify the containers that the Pod should run.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Manifest&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;greetings-pod&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;greetings-container&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dockeryu853/greetings:1.1&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's name the manifest above &lt;code&gt;greetings.yaml&lt;/code&gt;. To apply the manifest to your Kubernetes cluster, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; greetings.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running Pods
&lt;/h2&gt;

&lt;p&gt;Once a Pod is created, you can perform various operations to manage and inspect it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Listing Pods
&lt;/h3&gt;

&lt;p&gt;Run the command below to list all Pods in your cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pods
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdgvcfx0sr2eosj94z8iy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdgvcfx0sr2eosj94z8iy.png" alt="Image description" width="411" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the name of the Pod (&lt;em&gt;greetings-pod&lt;/em&gt;) that we gave it in the YAML file. In addition to the number of ready containers (1/1), the output also shows the status, the number of times the Pod was restarted, and the age of the Pod.&lt;/p&gt;

&lt;p&gt;If you ran this command immediately after the Pod was created, you might see:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyda4jco7lvgm2527qs9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyda4jco7lvgm2527qs9i.png" alt="Image description" width="472" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ContainerCreating&lt;/code&gt; means that Kubernetes has received the YAML manifest and is in the process of creating the containers specified in the manifest. If what you see in the status field is &lt;code&gt;Pending&lt;/code&gt;, it means that the Pod has been submitted but hasn’t been scheduled yet. If a more significant error occurs, such as an attempt to create a Pod with a container image that doesn’t exist, it will also be listed in the status field.&lt;/p&gt;

&lt;p&gt;To see a list of the pods running in your Kubernetes cluster and observe dynamic changes in real-time, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pods &lt;span class="nt"&gt;-w&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command above allows you to observe the dynamic changes in your Pod landscape without needing to repeatedly run the &lt;code&gt;kubectl get pods&lt;/code&gt; command. Press &lt;code&gt;Ctrl+C&lt;/code&gt; to exit watch mode.&lt;/p&gt;

&lt;p&gt;In addition, adding &lt;code&gt;-o wide&lt;/code&gt; to any kubectl command will print out slightly more information (while still keeping the information to a single line).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pods &lt;span class="nt"&gt;-o&lt;/span&gt; wide
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fii0t7pk5pobavgrpz1jt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fii0t7pk5pobavgrpz1jt.png" alt="Image description" width="800" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Pod Details
&lt;/h3&gt;

&lt;p&gt;To get detailed information about a specific Pod, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl describe pod &amp;lt;pod-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deleting a Pod
&lt;/h3&gt;

&lt;p&gt;To delete a Pod, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl delete pod &amp;lt;pod-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NB&lt;/strong&gt;: When you delete a Pod, any data stored in the containers associated with that Pod will be deleted as well. If you need to persist data across multiple instances of a Pod, you need to use Persistent Volumes, described at the end of this chapter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessing Your Pod
&lt;/h2&gt;

&lt;p&gt;Kubernetes provides several ways to interact with and troubleshoot Pods.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting More Information with Logs
&lt;/h3&gt;

&lt;p&gt;To view the logs of a container in a Pod, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl logs &amp;lt;pod-name&amp;gt; &lt;span class="nt"&gt;-c&lt;/span&gt; &amp;lt;container-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Running Commands in Your Containers with exec
&lt;/h3&gt;

&lt;p&gt;To execute a command in a running container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &amp;lt;pod-name&amp;gt; &lt;span class="nt"&gt;--&lt;/span&gt; &amp;lt;&lt;span class="nb"&gt;command&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To &lt;code&gt;exec&lt;/code&gt; into the &lt;code&gt;greetings-pod&lt;/code&gt;, run the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; greetings-pod /bin/sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To exit, simply run the &lt;code&gt;exit&lt;/code&gt; command inside the pod.&lt;/p&gt;

&lt;h3&gt;
  
  
  Copying Files to and From Containers
&lt;/h3&gt;

&lt;p&gt;To copy files between your local system and a container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;cp&lt;/span&gt; &amp;lt;file-path&amp;gt; &amp;lt;pod-name&amp;gt;:/path/in/container
kubectl &lt;span class="nb"&gt;cp&lt;/span&gt; &amp;lt;pod-name&amp;gt;:/path/in/container &amp;lt;local-path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Health Checks
&lt;/h2&gt;

&lt;p&gt;Kubernetes allows you to define health checks to ensure your containers are running as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Liveness Probe
&lt;/h3&gt;

&lt;p&gt;The liveness probe checks if a container is still running. If the check fails, Kubernetes restarts the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Liveness Probe&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/healthz&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
  &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Liveness Probe configuration above will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Wait 3 seconds after the container starts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send an HTTP GET request to &lt;a href="http://localhost:8080/healthz" rel="noopener noreferrer"&gt;http://localhost:8080/healthz&lt;/a&gt; every 3 seconds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the request fails or returns an error, Kubernetes will consider the container unhealthy and restart it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Readiness Probe
&lt;/h3&gt;

&lt;p&gt;The readiness probe checks if a container is ready to serve traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Readiness Probe&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/ready&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
  &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The readiness Probe configuration above will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Wait 3 seconds after the container starts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send an HTTP GET request to &lt;a href="http://localhost:8080/ready" rel="noopener noreferrer"&gt;http://localhost:8080/ready&lt;/a&gt; every 3 seconds.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the request succeeds (returns a 200 OK response), the container is considered ready to receive traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the request fails or returns an error, the container is not considered ready, and Kubernetes will not send traffic to it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Resource Management
&lt;/h2&gt;

&lt;p&gt;You can specify the resources that your Pod's containers require, ensuring they run efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resource Requests: Minimum Required Resources
&lt;/h3&gt;

&lt;p&gt;Resource requests define the minimum amount of resources a container needs. These requests serve as a hint to the Kubernetes scheduler to ensure the Pod is placed on a node with sufficient resources. If the node doesn't have enough resources, the Pod won't be scheduled to that node.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;64Mi"&lt;/span&gt;
      &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;250m"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pod in the YAML manifest above is requesting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;At least 64 MB of memory to be allocated&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At least 250 millicores (or 0.25 cores) of CPU processing power&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that these are requests, not limits. The container can use more resources if available, but it's guaranteed to get at least the requested amount.&lt;/p&gt;

&lt;h3&gt;
  
  
  Capping Resource Usage With Limits
&lt;/h3&gt;

&lt;p&gt;Resource limits specify the maximum resources a container can use. These limits prevent the container from consuming excessive resources and impacting other workloads running on the same node. If the container tries to use more resources than specified, Kubernetes will take action to enforce the limits, such as terminating the container if it exceeds the memory limit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;128Mi"&lt;/span&gt;
    &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500m"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Pod in the YAML manifest above is restricted to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Using no more than 128 MB of memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using no more than 500 millicores (or 0.5 cores) of CPU processing power&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Persisting Data with Volumes
&lt;/h2&gt;

&lt;p&gt;Kubernetes Volumes provide persistent storage to Pods, ensuring data is retained across restarts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Volumes with Pods
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;greetings-pod&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;greetings-container&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dockeryu853/greetings:1.1&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
    &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;static-files&lt;/span&gt;
      &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/static&lt;/span&gt;
  &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;static-files&lt;/span&gt;
    &lt;span class="na"&gt;hostPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/home/yusbuntu/static&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Directory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the YAML manifest above, the VolumeMount is trying to achieve the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It's mounting a volume named &lt;code&gt;static-files&lt;/code&gt; into the container at the path &lt;code&gt;/static&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The static-files volume is defined in the volumes section and is of type hostPath, which means it's a directory on the host machine (the machine running the Kubernetes node).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The path field specifies the directory on the host machine (in this case, my Minikube Virtual Machine), &lt;code&gt;/home/yusbuntu/static&lt;/code&gt;, which will be mounted into the container. Make sure to change &lt;code&gt;/home/yusbuntu&lt;/code&gt; to your home directory or any other path you prefer.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As stated earlier, if you are using Minikube, you have to create this directory inside Minikube and not on your computer. Below are the steps to follow to create the directory inside Minikube.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube ssh
&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /home/your_user_name/static
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to change &lt;code&gt;your_user_name&lt;/code&gt; to your actual user name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it all Together
&lt;/h2&gt;

&lt;p&gt;Kubernetes offers a comprehensive set of features, including persistent volumes for data storage, readiness and liveness probes for health monitoring, and resource restrictions for efficient resource allocation, making it an ideal platform for running stateful applications with high reliability and consistency. The manifest below puts this all together.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;greetings-pod&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;greetings-container&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dockeryu853/greetings:1.1&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
    &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;static-files&lt;/span&gt;
      &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/static&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;128Mi"&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500m"&lt;/span&gt;
      &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;64Mi"&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;250m"&lt;/span&gt;
    &lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/ready&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
      &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
      &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
    &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/healthz&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
      &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
      &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;static-files&lt;/span&gt;
    &lt;span class="na"&gt;hostPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/home/yusbuntu/static&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Directory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NB:&lt;/strong&gt; Before applying the &lt;code&gt;greetings.yaml&lt;/code&gt; manifest above, make sure to change the path (/home/yusbuntu/static) in your manifest to the path you specified in your Minikube VM.&lt;/p&gt;

&lt;p&gt;Next, apply the manifest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; greetings.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Follow the steps below to see the contents of the container:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Once the container starts running, run the command below:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pods &lt;span class="nt"&gt;-o&lt;/span&gt; wide
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F75yiu6w8mf741zu5l2oo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F75yiu6w8mf741zu5l2oo.png" alt="Image description" width="800" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;As you can see from the image above, my IP is 10.244.0.214&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next, SSH into Minikube:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the command below to see the contents of the container running inside the pod:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; curl http://10.244.0.214:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding Pods is fundamental to working with Kubernetes. They encapsulate your application's containers, along with their storage, network, and configuration, into a single deployable unit. By mastering Pods and their associated operations, you can effectively manage your applications in a Kubernetes environment.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Kubernetes!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Chapter 4 - Dockerfiles</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Tue, 27 Aug 2024 10:00:47 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-4-dockerfiles-pdh</link>
      <guid>https://dev.to/yusbuntu/chapter-4-dockerfiles-pdh</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
What is a Dockerfile?

&lt;ul&gt;
&lt;li&gt;Understanding Dockerfiles as Blueprints for Building Images.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Creating a Dockerfile

&lt;ul&gt;
&lt;li&gt;Basic Syntax and Structure&lt;/li&gt;
&lt;li&gt;Common Instructions&lt;/li&gt;
&lt;li&gt;Optimizing Image Builds&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is a Dockerfile?
&lt;/h2&gt;

&lt;p&gt;A Dockerfile is a text file that contains instructions for building a Docker image. It's a blueprint for creating an image, specifying the base image, dependencies, files, and commands required to create a container. By using a Dockerfile, you automate the process of creating an image. This makes it easier to build, test, and deploy applications in a reliable and efficient manner.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Dockerfiles as Blueprints for Building Images.
&lt;/h3&gt;

&lt;p&gt;Think of a Dockerfile as a recipe for building an image. Just as a recipe outlines ingredients and steps to prepare a dish, a Dockerfile outlines the steps to build an image. This blueprint approach allows for reproducible and consistent image builds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Dockerfile
&lt;/h2&gt;

&lt;p&gt;A Dockerfile consists of instructions, each starting with a keyword (e.g., FROM, RUN, COPY). The instructions are executed in order, from top to bottom. Just like when you add new ingredients to a dish you are preparing, each executed instruction in a Dockerfile adds or creates a new layer in the image.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Syntax and Structure
&lt;/h3&gt;

&lt;p&gt;A Dockerfile starts with the &lt;code&gt;FROM&lt;/code&gt; instruction, specifying the base image. Each instruction is followed by arguments, specifying the action to take.&lt;br&gt;
Instructions are executed in order, from top to bottom. Finally, comments in a Dockerfile start with a &lt;code&gt;#&lt;/code&gt; symbol.&lt;/p&gt;
&lt;h3&gt;
  
  
  Common Instructions
&lt;/h3&gt;

&lt;p&gt;Here are some common instructions you might find in a Dockerfile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;FROM&lt;/code&gt;: Specifies the base image. A base image is a pre-built Docker image that serves as the foundation for your new image. By using a base image, you don't need to start from scratch. You can focus on adding your own customizations, like your application code, dependencies, and settings, to create a new image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;RUN&lt;/code&gt;: Executes a command during the build process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;COPY&lt;/code&gt;: Copies files from the build context into the image. When you run the docker build command, Docker looks at the files and directories in the current directory (or the directory you specify) and uses them to create the image. This directory is called the build context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;CMD&lt;/code&gt;: Specifies the default command to run when the container starts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ENTRYPOINT&lt;/code&gt;: Specifies the command to run when the container starts, allowing for parameters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;EXPOSE&lt;/code&gt;: Exposes a port to the host machine. in other words, the &lt;code&gt;EXPOSE&lt;/code&gt; command exposes a port from a container to the host machine (the machine running the Docker daemon).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From the list of common instructions above, you might be wondering what the differences between the &lt;code&gt;CMD&lt;/code&gt; and &lt;code&gt;ENTRYPOINT&lt;/code&gt; commands are. Below are some key differences between them:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;span&gt;CMD&lt;/span&gt;&lt;/th&gt;
&lt;th&gt;&lt;span&gt;ENTRYPOINT&lt;/span&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sets the default command and arguments to run when the container starts&lt;/td&gt;
&lt;td&gt;Sets the command that should always be run when the container starts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can be overridden when running the container with a custom command&lt;/td&gt;
&lt;td&gt;Cannot be overridden (easily) when running the container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Think of it as the "default" or "fallback" command. CMD is like a suggestion: "Hey, you might want to run this command."&lt;/td&gt;
&lt;td&gt;Think of it as the "required" or "mandatory" command. ENTRYPOINT is like a requirement: "You must run this command."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here is an example of a Dockerfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use an official Node.js image as the base&lt;/span&gt;
FROM node:18

&lt;span class="c"&gt;# Set the working directory&lt;/span&gt;
WORKDIR /app

&lt;span class="c"&gt;# Copy package.json and package-lock.json&lt;/span&gt;
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./

&lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
RUN npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Copy the rest of the application&lt;/span&gt;
COPY &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Expose the port&lt;/span&gt;
EXPOSE 5000

&lt;span class="c"&gt;# Run the command when the container starts&lt;/span&gt;
CMD &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"npm"&lt;/span&gt;, &lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Dockerfile above creates a Node.js image, installs dependencies, copies the application code, exposes port 5000, and sets the default command to run when the container starts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optimizing Image Builds
&lt;/h3&gt;

&lt;p&gt;When building Docker images, speed and efficiency are crucial. A well-structured Dockerfile can significantly reduce image build times, making development and deployment processes more agile. When you build an image, Docker stores the results of each step (like installing dependencies) in a cache. If you make changes to your code, Docker can reuse the cached results for the steps that didn't change (like dependencies). This saves time and speeds up the build process. To take advantage of Docker's caching mechanism and reduce image build times, structure your Dockerfile in this order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Base image&lt;/strong&gt; (FROM): Start with the base image, as it rarely changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dependencies&lt;/strong&gt; (COPY): Install dependencies next, as they change less frequently than application code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Application code&lt;/strong&gt; (COPY): Copy application code last, as it changes most frequently. Unless neccessary, Use &lt;code&gt;COPY&lt;/code&gt; instead of &lt;code&gt;ADD&lt;/code&gt; to avoid unnecessary layer creation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Commands&lt;/strong&gt; (CMD, ENTRYPOINT, etc.): Finish with commands that set up the container.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This order maximizes caching because If the base image or dependencies don't change, Docker can reuse cached layers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, Dockerfiles are the blueprint for building Docker images, and mastering them is crucial for efficient containerization. By understanding the instructions, optimizing image builds, and leveraging caching, you can create lightweight, portable, and scalable images that streamline your development and deployment processes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Docker and DevOps!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Chapter 4 - DNS (Domain Name System)</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Tue, 27 Aug 2024 09:21:52 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-4-dns-domain-name-system-5a7n</link>
      <guid>https://dev.to/yusbuntu/chapter-4-dns-domain-name-system-5a7n</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The Domain Name System (DNS) is a critical component of the internet, responsible for translating human-readable domain names into IP addresses that computers use to identify each other on the network. This chapter covers the basics of DNS, including how it works and the different types of DNS records.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
What is DNS?

&lt;ul&gt;
&lt;li&gt;Understanding how domain names are translated to IP addresses&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

DNS Records

&lt;ul&gt;
&lt;li&gt;Common record types: &lt;em&gt;A, AAAA, CNAME&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is DNS?
&lt;/h2&gt;

&lt;p&gt;DNS is often referred to as the "phone book of the internet." It enables users to access websites using easy-to-remember domain names instead of difficult-to-remember IP addresses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding how domain names are translated to IP addresses
&lt;/h3&gt;

&lt;p&gt;When you type a domain name into your browser, the DNS system translates it into the corresponding IP address through a process called DNS resolution. Here's how it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DNS Query&lt;/strong&gt;: The browser sends a query to a DNS resolver to find the IP address associated with the domain name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Recursive Resolution&lt;/strong&gt;: The DNS resolver queries multiple DNS servers, starting with the root DNS server, then the top-level domain (TLD) server (e.g., .com), and finally, the authoritative DNS server for the specific domain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Response&lt;/strong&gt;: The authoritative DNS server responds with the IP address, which is then sent back to the browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Connection&lt;/strong&gt;: The browser connects to the web server using the IP address and loads the website.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  DNS Records
&lt;/h2&gt;

&lt;p&gt;DNS records are used to store various types of data about a domain. Each record type serves a different purpose.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common record types: &lt;em&gt;A, AAAA, CNAME&lt;/em&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A Record (Address Record)&lt;/strong&gt;: This maps a domain name to an IPv4 address. For example, the domain name &lt;code&gt;example.com&lt;/code&gt; could be mapped to an IPv4 address &lt;code&gt;192.0.2.1&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AAAA Record (IPv6 Address Record)&lt;/strong&gt;: This maps a domain name to an IPv6 address. For example, the domain name &lt;code&gt;example.com&lt;/code&gt; could be mapped to an IPv6 address &lt;code&gt;2001:0db8:85a3:0000:0000:8a2e:0370:7334&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CNAME Record (Canonical Name Record)&lt;/strong&gt;: This maps a domain name to another domain name, creating an alias. This is useful for pointing multiple subdomains to the same IP address indirectly. For example, the subdomain &lt;code&gt;www.example.com&lt;/code&gt; could be mapped to another domain name, &lt;code&gt;example.org&lt;/code&gt;. In this example, &lt;code&gt;www.example.com&lt;/code&gt; is the alias, and &lt;code&gt;example.org&lt;/code&gt; is the canonical name (or the target). The CNAME record essentially tells DNS resolvers that &lt;code&gt;www.example.com&lt;/code&gt; should be resolved to the same IP address as &lt;code&gt;example.org&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;DNS is a foundational technology that makes the internet user-friendly by allowing the use of domain names instead of numerical IP addresses. Understanding DNS and its various record types is crucial for managing and troubleshooting network and domain-related issues.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Networking!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Chapter 4 - Gitignore</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Tue, 27 Aug 2024 08:42:32 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-4-gitignore-1ojc</link>
      <guid>https://dev.to/yusbuntu/chapter-4-gitignore-1ojc</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
What is Gitignore?

&lt;ul&gt;
&lt;li&gt;Why use Gitignore?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;How to use Gitignore&lt;/li&gt;

&lt;li&gt;

Conclusion

&lt;ul&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Gitignore?
&lt;/h2&gt;

&lt;p&gt;Gitignore is a file in Git repositories that tells Git which files or directories to ignore and not track. It's a crucial file for managing your project's repository, ensuring that unnecessary files don't clutter your version control system.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;/h3&gt;
&lt;p&gt;Why use Gitignore?&lt;/p&gt;


&lt;p&gt;Here are a few reasons you might want to include a Gitignore file in your project's directory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Exclude sensitive information:&lt;/strong&gt; Keep sensitive files like API keys, passwords, or personal data out of your repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduce repository size:&lt;/strong&gt; Ignore large files, logs, or temporary files that don't need version control.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enhance Collaboration:&lt;/strong&gt; Prevent team members from committing unnecessary files, reducing conflicts and merge issues.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How to use Gitignore
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In your repository's root directory, create a file named &lt;code&gt;.gitignore&lt;/code&gt; (note the dot prefix).
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;touch&lt;/span&gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Open the Gitignore file you created using your preferred text editor, e.g., nano.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   nano .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Inside this file, add files and/or directories you do not want committed to Github. Below is an imaginary Gitignore file:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="c"&gt;# Ignore log files&lt;/span&gt;
   &lt;span class="k"&gt;*&lt;/span&gt;.log

   &lt;span class="c"&gt;# Ignore node_modules directory&lt;/span&gt;
   node_modules/

   &lt;span class="c"&gt;# Ignore environment configuration files&lt;/span&gt;
   &lt;span class="k"&gt;*&lt;/span&gt;.env

   &lt;span class="c"&gt;# Ignore temp directory and its contents&lt;/span&gt;
   temp/

   &lt;span class="c"&gt;# Ignore a file called secrets.txt&lt;/span&gt;
   secrets.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The imaginary .gitignore file above tells Git to ignore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;All files with the .log extension&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The entire node_modules directory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Environment configuration files (*.env)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The temp directory and its contents&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A file named secrets.txt&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep your .gitignore up-to-date:&lt;/strong&gt; Regularly review and update your .gitignore file as your project evolves.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Communicate with your team:&lt;/strong&gt; Ensure all team members understand what's being ignored and why.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By mastering Gitignore, you'll maintain a clean, efficient, and secure repository, making collaboration and version control a breeze.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to comment and share this article. Please follow my blog for more insights on Git and GitHub!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Chapter 4 - Text Editors</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Tue, 27 Aug 2024 08:14:25 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-4-text-editors-2n5h</link>
      <guid>https://dev.to/yusbuntu/chapter-4-text-editors-2n5h</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Few48py10jc1gv249r8ev.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Few48py10jc1gv249r8ev.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Text editors are essential tools in Linux for editing configuration files, writing scripts, and even developing software. In this chapter, we will explore some of the most commonly used text editors and their basic usage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
Common Text Editors

&lt;ul&gt;
&lt;li&gt;
nano

&lt;ul&gt;
&lt;li&gt;Features of nano:&lt;/li&gt;
&lt;li&gt;Installation&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

vim

&lt;ul&gt;
&lt;li&gt;Features of vim:&lt;/li&gt;
&lt;li&gt;Installation&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;

Basic Usage

&lt;ul&gt;
&lt;li&gt;Opening Files&lt;/li&gt;
&lt;li&gt;Editing Files&lt;/li&gt;
&lt;li&gt;Saving Files&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Text Editors
&lt;/h2&gt;

&lt;p&gt;Linux offers a variety of text editors, each with its own unique features and user interface. Two of the most commonly used text editors are &lt;code&gt;nano&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  nano
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;nano&lt;/code&gt; is a simple, user-friendly text editor that is ideal for beginners. It provides an easy-to-use interface with straightforward commands displayed at the bottom of the screen.&lt;/p&gt;

&lt;h4&gt;
  
  
  Features of nano:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Easy to learn and use&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commands are displayed at the bottom of the screen&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Suitable for quick edits and small files&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Installation
&lt;/h4&gt;

&lt;p&gt;NB: &lt;code&gt;nano&lt;/code&gt; is installed by default on many Linux distributions, so you might not need to install it explicitly. You can check if it is already installed by running &lt;code&gt;nano --version&lt;/code&gt; in your terminal. If it is not installed, here are the commands for installing &lt;code&gt;nano&lt;/code&gt; on various Linux distributions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Debian/Ubuntu:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;nano
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fedora:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;nano
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Red Hat Enterprise Linux (RHEL)/CentOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;nano
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;openSUSE:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;zypper &lt;span class="nb"&gt;install &lt;/span&gt;nano
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Arch Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; nano
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  vim
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;vim&lt;/code&gt; (Vi IMproved) is a powerful and highly configurable text editor. It is an enhanced version of the older &lt;code&gt;vi&lt;/code&gt; editor. &lt;code&gt;vim&lt;/code&gt; offers a wide range of advanced features and flexibility, but it has a steeper learning curve compared to &lt;code&gt;nano&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Features of vim:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Highly customizable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports multiple modes (&lt;em&gt;normal, insert, visual, and command-line&lt;/em&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extensive plugin ecosystem&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Suitable for complex editing tasks and large projects&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Installation
&lt;/h4&gt;

&lt;p&gt;NB: &lt;code&gt;vim&lt;/code&gt; is installed by default on many Linux distributions, so you might not need to install it explicitly. You can check if it is already installed by running &lt;code&gt;vim --version&lt;/code&gt; in your terminal. If it is not installed, here are the commands for installing &lt;code&gt;vim&lt;/code&gt; on various Linux distributions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Debian/Ubuntu:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;vim
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fedora:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;vim
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Red Hat Enterprise Linux (RHEL)/CentOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;vim
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;openSUSE:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;zypper &lt;span class="nb"&gt;install &lt;/span&gt;vim
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Arch Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; vim
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic Usage
&lt;/h2&gt;

&lt;p&gt;Now that we are familiar with &lt;code&gt;nano&lt;/code&gt; and &lt;code&gt;vim&lt;/code&gt;, let's explore their basic usage, including how to open, edit, save, and close files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Opening Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;nano&lt;/strong&gt;: To open a file with &lt;code&gt;nano&lt;/code&gt;, use the following command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the file does not exist, &lt;code&gt;nano&lt;/code&gt; will create a new file with the specified name.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;vim&lt;/strong&gt;: To open a file with &lt;code&gt;vim&lt;/code&gt;, use the following command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vim filename
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similar to &lt;code&gt;nano&lt;/code&gt;, if the file does not exist, &lt;code&gt;vim&lt;/code&gt; will create a new file with the specified name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Editing Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;nano&lt;/strong&gt;: In &lt;code&gt;nano&lt;/code&gt;, you can start typing to edit the file. The arrow keys can be used to navigate through the text.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;vim&lt;/strong&gt;: In &lt;code&gt;vim&lt;/code&gt;, you need to switch to insert mode to edit the text. Press &lt;code&gt;i&lt;/code&gt; to enter insert mode, then start typing. To return to normal mode, press &lt;code&gt;Esc&lt;/code&gt; or &lt;code&gt;ctrl&lt;/code&gt; + &lt;code&gt;[&lt;/code&gt; keys.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Saving Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;nano&lt;/strong&gt; To save changes in &lt;code&gt;nano&lt;/code&gt;, press &lt;code&gt;Ctrl&lt;/code&gt; + &lt;code&gt;O&lt;/code&gt;, then press &lt;code&gt;Enter&lt;/code&gt; to confirm the filename. Then press &lt;code&gt;Ctrl&lt;/code&gt; + &lt;code&gt;X&lt;/code&gt; to exit the editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;vim&lt;/strong&gt; To close &lt;code&gt;vim&lt;/code&gt;, first ensure you are in normal mode by pressing &lt;code&gt;Esc&lt;/code&gt; or &lt;code&gt;ctrl&lt;/code&gt; + &lt;code&gt;[&lt;/code&gt; keys, then type &lt;code&gt;:q&lt;/code&gt; and press Enter. If there are unsaved changes, you can use &lt;code&gt;:wq&lt;/code&gt; to save and exit or &lt;code&gt;:q!&lt;/code&gt; to exit forcefully without saving.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this chapter, we covered two common text editors in Linux: &lt;strong&gt;nano&lt;/strong&gt; and &lt;strong&gt;vim&lt;/strong&gt;. We explored their basic usage, including how to open, edit, save, and close files. Whether you are a beginner or an advanced user, knowing how to use at least one of these text editors will enhance your ability to manage and configure your Linux system efficiently.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Linux!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Chapter 3 - Setting up Kubernetes</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Tue, 20 Aug 2024 17:14:48 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-3-setting-up-kubernetes-25ja</link>
      <guid>https://dev.to/yusbuntu/chapter-3-setting-up-kubernetes-25ja</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Setting up a Kubernetes environment is the first step in learning how to deploy and manage containerized applications. This chapter will guide you through setting up a local Kubernetes cluster using Minikube and provide an overview of cloud-based Kubernetes setups using managed services like GKE, EKS, and AKS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
Local Setup with Minikube

&lt;ul&gt;
&lt;li&gt;Installing Minikube&lt;/li&gt;
&lt;li&gt;Installing Kubectl&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Cloud-based  Kubernetes Setup

&lt;ul&gt;
&lt;li&gt;Google Kubernetes Engine (GKE)&lt;/li&gt;
&lt;li&gt;Amazon Elastic Kubernetes Service (EKS)&lt;/li&gt;
&lt;li&gt;Azure Kubernetes Service (AKS)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Local Setup with Minikube
&lt;/h2&gt;

&lt;p&gt;Minikube is a tool that allows you to run a single-node Kubernetes cluster on your local machine. It is ideal for learning, testing, and development purposes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Minikube
&lt;/h3&gt;

&lt;p&gt;To install Minikube, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install Minikube:&lt;/strong&gt; Download and install minikube from the &lt;a href="https://minikube.sigs.k8s.io/docs/start" rel="noopener noreferrer"&gt;official minikube website&lt;/a&gt;. Ensure to download the version that is compatible with your operating system (Linux, Windows, or MacOS) and architecture. If you are using a MacOS or Linux operating system, you can find out the architecture of your system using the command below:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;uname&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are using Windows, you can find out the architecture of your system by opening your PowerShell terminal as an administrator and running the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```sh   
wmic os get osarchitecture
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can also run the command below to find out the architecture of your Windows machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```sh
systeminfo | findstr /C:"System Type"
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing minikube, you can verify if the installation was successful through the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```sh
minikube version
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If there is no output, it means the installation wasn't successful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Kubectl
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;kubectl&lt;/code&gt; is a command-line tool for interacting with your Kubernetes cluster. Follow these steps to install &lt;code&gt;kubectl&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download the latest release with the command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  curl &lt;span class="nt"&gt;-LO&lt;/span&gt; &lt;span class="s2"&gt;"https://dl.k8s.io/release/&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; https://dl.k8s.io/release/stable.txt&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/bin/linux/amd64/kubectl"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Make the kubectl binary executable:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;chmod&lt;/span&gt; +x kubectl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Move the binary in to your PATH:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo mv &lt;/span&gt;kubectl /usr/local/bin/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify the installation of kubectl and also check the version installed through the command below:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  kubectl version &lt;span class="nt"&gt;--client&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Configure kubectl to interact with your Minikube cluster.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  kubectl config use-context minikube
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Next, start your Minikube cluster with the command below:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  minikube start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command above will start a virtual machine and set up a Kubernetes cluster within it. The command also automatically uses Docker as the default driver for Minikube (that is if Docker is installed). Other drivers that Minikube can use include VirtualBox, VMware, HyperKit, and Podman. To specify a specific driver (e.g., VirtualBox), use the "-driver" flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  minikube start &lt;span class="nt"&gt;--driver&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;VirtualBox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once your Minikube cluster is up and running, run the command below to verify that everything is working perfectly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  kubectl get nodes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is working perfectly, the command above should display a single node with the status "Ready".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To stop your Minikube cluster, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  minikube stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you want to delete your minikube cluster, use the command below:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  minikube delete
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cloud-based  Kubernetes Setup
&lt;/h2&gt;

&lt;p&gt;For production environments, it is recommended to use managed Kubernetes services offered by cloud providers. These services handle the complexity of setting up and managing Kubernetes clusters, allowing you to focus on deploying and managing your applications. One important point you should note is that unlike Minikube, which is free, cloud-based Kubernetes setups incur costs and you will be billed accordingly. Here are three popular managed Kubernetes services:&lt;/p&gt;

&lt;h3&gt;
  
  
  Google Kubernetes Engine (GKE)
&lt;/h3&gt;

&lt;p&gt;Google Kubernetes Engine (GKE) is a managed Kubernetes service provided by Google Cloud Platform. It offers automatic updates, scaling, and a highly available control plane. To get started with GKE, you need a Google Cloud&lt;br&gt;
Platform account with billing enabled and the &lt;a href="https://cloud.google.com/sdk/docs/install" rel="noopener noreferrer"&gt;gcloud tool&lt;/a&gt; installed. Once you have gcloud installed, follow the remaining steps below to set up your GKE cluster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set a Default Zone&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   gcloud config &lt;span class="nb"&gt;set &lt;/span&gt;compute/zone us-west1-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create a GKE Cluster&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   gcloud container clusters create my-cluster &lt;span class="nt"&gt;--zone&lt;/span&gt; us-central1-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Get Authentication Credentials&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   gcloud container clusters get-credentials my-cluster &lt;span class="nt"&gt;--zone&lt;/span&gt; us-central1-a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploy an Application&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   kubectl create deployment hello-gke &lt;span class="nt"&gt;--image&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gcr.io/google-samples/hello-app:1.0
   kubectl expose deployment hello-gke &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;LoadBalancer &lt;span class="nt"&gt;--port&lt;/span&gt; 80 &lt;span class="nt"&gt;--target-port&lt;/span&gt; 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Amazon Elastic Kubernetes Service (EKS)
&lt;/h3&gt;

&lt;p&gt;Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service provided by Amazon Web Services (AWS). It integrates with other AWS services, providing a secure and scalable environment for running Kubernetes clusters.&lt;br&gt;
Before getting started with EKS, first install the &lt;a href="https://eksctl.io/" rel="noopener noreferrer"&gt;open source eksctl&lt;br&gt;
command-line tool&lt;/a&gt;. Once you have eksctl installed and in your path, follow the remaining steps below to set up your EKS cluster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create an EKS Cluster&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   eksctl create cluster &lt;span class="nt"&gt;--name&lt;/span&gt; my-cluster &lt;span class="nt"&gt;--region&lt;/span&gt; us-west-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Configure kubectl&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   aws eks &lt;span class="nt"&gt;--region&lt;/span&gt; us-west-2 update-kubeconfig &lt;span class="nt"&gt;--name&lt;/span&gt; my-cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploy an Application&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   kubectl create deployment hello-eks &lt;span class="nt"&gt;--image&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;amazon/amazon-ecs-sample
   kubectl expose deployment hello-eks &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;LoadBalancer &lt;span class="nt"&gt;--port&lt;/span&gt; 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Azure Kubernetes Service (AKS)
&lt;/h3&gt;

&lt;p&gt;Azure Kubernetes Service (AKS) is a managed Kubernetes service provided by Microsoft Azure. It offers integrated CI/CD capabilities and security features. Before getting started with AKS, first install the &lt;a href="https://github.com/Azure/azure-cli" rel="noopener noreferrer"&gt;az CLI&lt;/a&gt;. Once you have installed az CLI, follow the remaining steps below to set up your AKS cluster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create an AKS Cluster&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   az aks create &lt;span class="nt"&gt;--resource-group&lt;/span&gt; myResourceGroup &lt;span class="nt"&gt;--name&lt;/span&gt; myAKSCluster &lt;span class="nt"&gt;--node-count&lt;/span&gt; 1 &lt;span class="nt"&gt;--enable-addons&lt;/span&gt; monitoring &lt;span class="nt"&gt;--generate-ssh-keys&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Get AKS Credentials&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   az aks get-credentials &lt;span class="nt"&gt;--resource-group&lt;/span&gt; myResourceGroup &lt;span class="nt"&gt;--name&lt;/span&gt; myAKSCluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploy an Application&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   kubectl create deployment hello-aks &lt;span class="nt"&gt;--image&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nginx
   kubectl expose deployment hello-aks &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;LoadBalancer &lt;span class="nt"&gt;--port&lt;/span&gt; 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Setting up Kubernetes can be done locally using Minikube for learning and development, or using managed Kubernetes services for production environments. Whether you choose a local setup or a cloud-based setup, Kubernetes provides a robust platform for managing containerized applications at scale.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Kubernetes!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>minikube</category>
      <category>aks</category>
      <category>eks</category>
    </item>
    <item>
      <title>Chapter 3 - Docker Containers</title>
      <dc:creator>Yusuf Isah</dc:creator>
      <pubDate>Tue, 20 Aug 2024 16:21:25 +0000</pubDate>
      <link>https://dev.to/yusbuntu/chapter-3-docker-containers-3ho6</link>
      <guid>https://dev.to/yusbuntu/chapter-3-docker-containers-3ho6</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpczvu3jfa869mft4g653.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpczvu3jfa869mft4g653.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Docker containers are the building blocks of modern containerized applications. In this chapter, we'll delve into the world of Docker containers, exploring their fundamental concepts, basic operations, and essential management tasks. You'll learn how containers are instances of images, how to run, list, inspect, and access containers, and how to perform basic container lifecycle operations such as stopping, starting, restarting, and removing. By the end of this chapter, you'll have a solid understanding of Docker containers and be equipped with the skills to effectively work with them in your containerized applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
Docker Containers

&lt;ul&gt;
&lt;li&gt;Understanding Containers as Instances of Images&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Basic Container Operations

&lt;ul&gt;
&lt;li&gt;Running a Container&lt;/li&gt;
&lt;li&gt;Listing Running Containers&lt;/li&gt;
&lt;li&gt;Inspecting Containers&lt;/li&gt;
&lt;li&gt;Accessing a Running Container&lt;/li&gt;
&lt;li&gt;Stopping, Starting, Restarting, and Removing Containers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Conclusion&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Docker Containers
&lt;/h2&gt;

&lt;p&gt;A Docker container is a lightweight and standalone executable package that includes everything an application needs to run, such as code, libraries, and dependencies. Containers are isolated from each other and the host system, ensuring consistent behavior and performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Containers as Instances of Images
&lt;/h3&gt;

&lt;p&gt;Containers are created from Docker images, which are templates that define the container's configuration and contents. When you run a container, Docker creates an instance of the image, allowing multiple containers to share the same image. This approach ensures efficient resource utilization and enables easy deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Container Operations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Running a Container
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;To run a Docker container, you can use the &lt;code&gt;docker run&lt;/code&gt; command. This command creates a new container from a specified image and starts it. For example:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="o"&gt;[&lt;/span&gt;OPTIONS] IMAGE &lt;span class="o"&gt;[&lt;/span&gt;COMMAND] &lt;span class="o"&gt;[&lt;/span&gt;ARG...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's breakdown the command above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker run&lt;/code&gt;: The command to create and start a new container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[OPTIONS]&lt;/code&gt;: Optional flags that modify the container's behavior (e.g., &lt;code&gt;-it&lt;/code&gt; for interactive mode, &lt;code&gt;-p&lt;/code&gt; for port mapping, or &lt;code&gt;-d&lt;/code&gt; for detached/daemon mode).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;IMAGE&lt;/code&gt;: The Docker image to use as a template for the container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[COMMAND]&lt;/code&gt;: The command to run inside the container (if not specified, the image's default command is used).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[ARG...]&lt;/code&gt;: Arguments passed to the command (if any).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80:80 &lt;span class="nt"&gt;--name&lt;/span&gt; webserver nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command above runs an Nginx web server named &lt;code&gt;webserver&lt;/code&gt; in detached mode, mapping port 80 of the host to port 80 of the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  Listing Running Containers
&lt;/h3&gt;

&lt;p&gt;To list all running containers, use the &lt;code&gt;docker ps&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command above will show a list of all currently running containers with details such as container ID, image name, and status.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inspecting Containers
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;docker inspect&lt;/code&gt; command to get detailed information about a container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker inspect &lt;span class="o"&gt;[&lt;/span&gt;container_id]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Accessing a Running Container
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;docker exec&lt;/code&gt; command to run commands inside a running container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;container_id] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; 929374hfh573hdjf /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's breakdown what the command above is doing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;docker exec&lt;/code&gt; is the command to execute a command inside a running container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-it&lt;/code&gt; allocates a pseudo-TTY and keeps the container running after the command finishes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;929374hfh573hdjf&lt;/code&gt; is the container ID.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;/bin/bash&lt;/code&gt; is the command to run inside the container (in this case, starts a new Bash shell).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Stopping, Starting, Restarting, and Removing Containers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stopping a Container:&lt;/strong&gt; To stop a running container, use the &lt;code&gt;docker stop&lt;/code&gt; command followed by the container ID or name.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop &lt;span class="o"&gt;[&lt;/span&gt;container_id]
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Starting a Container:&lt;/strong&gt; To start a stopped container, use the &lt;code&gt;docker start&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker start &lt;span class="o"&gt;[&lt;/span&gt;container_id]
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Restarting a Container:&lt;/strong&gt; To restart a running container, use the &lt;code&gt;docker restart&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker restart &lt;span class="o"&gt;[&lt;/span&gt;container_id]
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Removing Containers:&lt;/strong&gt; To remove a stopped container, use the &lt;code&gt;docker rm&lt;/code&gt; command, followed by the container ID.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;container_id]
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to remove a running container, you can use the &lt;code&gt;-f&lt;/code&gt; option to forcefully remove it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;container_id]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this chapter, we defined Docker containers. We also learned how to run containers, list and inspect them, access their shells, and perform basic operations like stopping, starting, and removing. By mastering these essential skills, you're on your way to efficiently deploy and manage applications in a containerized environment.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave comments and share this article. Follow my blog for more insights on Docker and DevOps!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dockercontainers</category>
    </item>
  </channel>
</rss>
