Kubernetes Beginner's Guide: Getting Started

Kubernetes Main Components

  • Pods: The smallest and simplest Kubernetes object. A pod represents a set of running containers on your cluster.

  • Services: An abstraction that defines a logical set of pods and a policy by which to access them.

  • Deployments: Provide declarative updates to applications. You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate.

  • ReplicaSets: Ensure a specified number of pod replicas are running at any given time.

Understanding Kubernetes Architecture

Key Components of Kubernetes

  1. Kube-API Server: The control plane component that exposes the Kubernetes API. It is the front-end for the Kubernetes control plane. It is the only entry point to cluster . Client sends request to api server to get things done. For example : To create a pod

  2. Kube-Scheduler: Then comes scheduler it watches for newly created pods with no assigned node and selects a node for them to run on. Basically It consists of logic to assign pod to which node . It schedules pod but it doesn't start it.

  3. Kube-Controller-Manager: Runs controllers, which regulate the state of the cluster, ensuring it matches the desired state defined in your configurations.

  4. etcd: A consistent and highly-available key-value store used as Kubernetes' backing store for all cluster data. It consists of all the changes that happens in the cluster which is useful for other components like scheduler and Controller manager.

  5. Kubelet: An agent that runs on each node in the cluster. It starts the Pod . It ensures containers are running in a pod.

  6. Kube-Proxy: Maintains network rules on nodes. These network rules allow network communication to your pods from network sessions inside or outside of your cluster. It contains the forwarding logic to forward request

  7. Container Runtime: The software responsible for running containers. Kubernetes supports various runtimes, such as Docker, container d, and CRI-O.

Deploying and Managing an NGINX Deployment on Minikube: A Step-by-Step Guide

In this blog post, we'll walk through the process of deploying and managing an NGINX deployment on a Minikube cluster. We'll also describe the key Kubernetes commands used and provide a brief overview of Kubernetes architecture and its main components.

Prerequisites

Before we begin, ensure you have the following installed on your machine:

Setting Up Minikube

  1. Start Minikube:

     minikube start
    
  2. Check Minikube Status:

     minikube status
    

    Deploying NGINX : Main kubectl commands

    1. Creating an NGINX Deployment:

       // kubectl create deployment name --image=image
       kubectl create deployment nginx-depl --image=nginx
      
       // Verify the Deployment:
       kubectl get deployment
       kubectl get pod
       kubectl get replicaset
      
        /* TO EDIT DEPLOYMENT FOR EXAMPLE ADD TAG IN IMAGE => nginx:1.2 */ 
      
       // kubectl edit deployment name
       kubectl edit deployment  nginx-depl
      
        /* AFTER THIS : UPON RUNNING BELOW COMMANDS 
        YOU WILL GET A NEW  POD CREATED */ 
      
       kubectl get pod
       kubectl get replicaset 
      
       /* To execute a command inside a running pod, use: */
       kubectl exec -it <pod-name> -- /bin/bash
      
       /* TO DELETE DEPLOYMENT */
      
       // kubectl delete deployment name
       kubectl delete deployment  nginx-depl
      

      2. Stop Minikube

      Stop the Minikube cluster when you are done:

       minikube stop
      

      Conclusion

      This guide provides a basic understanding of setting up and managing a Kubernetes deployment using Minikube. By following these steps and understanding the core components of Kubernetes, you can effectively deploy and manage containerized applications in your local development environment. For more advanced scenarios, follow my upcoming blogs.