A Comprehensive Introduction to Kubernetes

  • It is a open source container orchestration tool.

  • Kubernetes is used to deploy any type of containers.

  • It is used to ensure High availability of the applications/services running through containers.

  • Used to ensure high availability of containers by creating replicas of container.

  • It supports auto scaling and load balancing.

Kubernetes Concepts / Terminologies

  • Kubernetes_Master

    • Used to Create and Schedule the Deployments to Kubernetes_WorkerNodes
  • Kubernetes_WorkNodes

    • Target Sever
  • KUBECTL

    • Is a Command Line Utility to interract with Kubernetes Master.

Kubernetes Architecture & its Components!

  • API_Server

    • Acts as interface to the Kubernetes.
  • etcd

    • Single point of source for Kubernetes components
  • Scheduler

    • To identify the health node for deployments
  • Controller Manager

    • To run the pods in its desired state.
  • Kubelet

    • It is a Kubernetes agent used to create and deploy the pods.
  • KubeProxy

    • Is used to enable pod networking by creating pod IP address.
  • CRI - Container RunTime Interface

    • It is used to identify the image from the container Registry for deployment
  • PODS

    • Atomic unit of Schedule

    • Smallest unit of Task

    • Any Task we execute in Kubernetes will be executed as Pod

    • Pod runs the container within that.

  • Kubernetes Cluster

    • Kubernetes Cluster is a Collection of Worker Nodes

Install and Configure Kubernetes Master Node and Worker Nodes using Kubeadm

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

For detailed installation steps redirect to this blog post

High level overview of installation process

  • Need 3 nodes

    • Kubernetes Master

    • Kubernetes_WorkNode1

    • Kubernetes_WorkNode2

  • Following Commands to be executed in all the Nodes(Master&Worker)

    1. Launch 3 EC2 Instances - Ubuntu v22.04

    2. Update Inbound Rule - Security Group

    3. Set the Host Name

      1. Disable Swap
    4. Install Docker

    5. Install Container-D (CRI)

      1. Configure Net-Filter Module

      2. Configure IP6 Table Ref.

      3. Download Container-Package using curl command

      4. Install Container-D

      5. Configure Container-D Config.toml file

      6. Restart Container-D

    6. Install Kubeadm,Kubectl,Kubelet

      1. Download using curl command

      2. Install

      3. Enable kubelet

  • Following Commands to be executed only in Master Node

    1. kubeadm init # To initialize Master Node
  • Following Commands to be executed in all Worker Nodes

    1. kubeadm join # To Attach Worker Nodes to Master Node.

Create a Pod

# nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: nginx
    tier: dev
spec:
  containers:
  - name: nginx-container
    image: nginx
    ports:
    - containerPort: 80

Create and display Pods

kubectl create -f nginx-pod.yaml
kubectl get pod
kubectl get pod -o wide   #To get the ip address of the pod
kubectl get pod nginx-pod -o yaml   #To read the actual YAML file
kubectl describe pod nginx-pod  # TO get the complete properties

Test & Delete

  • To Login to the Pod

      kubectl exec -it nginx-pod -- bash
      exit
    
  • Expose PODS using NodePort service

    • Node-Port Range : 30000 - 32767

        kubectl expose pod nginx-pod --type=NodePort --port=80
      

  • Display Service and find NodePort

      kubectl describe svc nginx-pod
    

  • Open Web-browser and access webpage using

    •   http://<external-nodeip>:<nodeport>
      

Delete pod & svc

kubectl delete svc nginx-pod
kubectl delete pod nginx-pod