top of page
Search

Kubernetes walk-through

  • Writer: Vishal Arora
    Vishal Arora
  • Dec 19, 2021
  • 3 min read

Updated: Mar 12, 2022

Kubernetes (k8s) is an open-source system for automating deployment, scaling, and management of containerized applications.

  • We can schedule containers on a cluster of servers.

  • We can run multiple containers on one server.

  • K8s manage the state of these containers

Advantages of Kubernetes

  • We can run Kubernetes on-premise(Own datacenter), public cloud (AWS, Google Cloud), and Hybrid cloud.

  • It is open-source software that has a huge community base.

  • It's modular and can be customized as per need.


Architecture Overview




Control Plane Components

  • kube-apiserver

  • etcd

  • kube-controller

  • kube-scheduler

Master Node

Responsible for the management of the k8s cluster. Perform all administrative tasks and manage the worker nodes. Below are the components of Master Node.


Kube-apiserver

The entry point for all REST commands is used to control the cluster. It processes the REST requests, validates them, and executes the same.


etcd storage

etcd storage acts as a datastore which provides a highly available key-value store for persisting cluster state. it stores object and config information.


Kube-controller-manager

Monitor the cluster state via the API server which checks the shared state of the cluster and makes changes to the current state to change it to the desired one.

Example - Replication controller which takes care of the number of pods in the system. it will automatically maintain the desired state of the pod defined in the YAML file.


Kube-Scheduler

It is responsible for the deployment of configured pods and services into nodes. it contains the information regarding resources available on the members of the cluster, as well as the ones required for the configured.


Node Components

  • kubelet

  • kube-proxy

  • pod

  • Container Runtime Engine i.e Docker

Worker Node

The pods which contain the application are executed on a worker node. It contains all services to manage the networking between the container, communicate with the master node, and assign resources to the container scheduling. Below are the components of the worker node.

Kubelet

Kubelet gets the configuration of a pod from the apiserver and ensures that all defined containers are up and running. This is the worker service that's responsible for communicating with the master node. It also coordinates with etcd storage service running on the master node to get information about services.


Kube-proxy

Kube-proxy acts as a network proxy and a load balancer for a service on a single worker node. It's also responsible for network routing for TCP and UDP packets.


Pods

The smallest unit of work of K8s, pods contain one or more containers that share volume, network, and namespace. Pods are deployed on worker/minion nodes. Pods describe an application running on K8s. Pods are created, destroyed, and recreated on demand based on the state of server and service


Container Runtime Engine

Docker is a container engine that runs on each of the worker nodes and runs the configured pods. It's responsible for downloading the images and running the containers.



Time to do some demo and set up an application in Kubernetes using Kind cluster.


Kind is used to locally run Kubernetes for testing purposes. Let's set up the Kubernetes cluster with kind. Kind requires docker, kubectl, and kind packages to be installed.


OS - Ubuntu 18.04.6 LTS


Install docker


sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
sudo apt install docker-ce -y 
sudo systemctl status docker

Install kubectl binary


curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
 
kubectl version --client

Install kind binary


curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
mv ./kind /usr/local/bin
kind version

Now let’s create the cluster using the below command.


git clone https://github.com/vishal267/thefinisher

cd thefinisher/kind

kind create cluster --name k8s-cluster --config node-cluster.yaml



Check the status and ready nodes of the Kubernetes cluster


kubectl cluster-info --context kind-k8s-cluster



Now let's deploy the hello app using the YAML file provided in the git repo that creates the deployment and NodePort service in a kind cluster.


git clone https://github.com/vishal267/thefinisher

cd thefinisher/hello-app/



Now we will fetch the system private IP using the below command and use curl to make API requests.


/sbin/ifconfig eth0 | grep 'inet ' | awk '{ print $2}'


curl 172.31.21.175:30000




Recent Posts

See All
Never Miss a Post. Subscribe Now!

Learning Starts Here

Thanks for submitting!

© 2023 by Kathy Schulders. Proudly created with Wix.com 

  • Grey Twitter Icon
bottom of page