Kubernetes Architecture and Components, Kubernetes Installation and Configuration

Kubeweek Challenge - Day 1

What is Kubernetes?

Kubernetes (K8s) is an open-source container management platform that automates container deployment, scaling, and load balancing. It plans, executes, and manages isolated containers running on virtual/physical/cloud machines. Kubernetes is supported by all major cloud providers.

Originally owned by Google, Kubernetes was donated to the Cloud Native Computing Foundation (CNCF) in 2014.

Why Kubernetes is called K8s?

Kubernetes (sometimes shortened to K8s with the 8 standing for the number of letters between the “K” and the “s”)

Features of Kubernetes

  • Container orchestration

  • Self Healing

  • High availability

  • Horizontal Scaling

  • Persistent storage

  • Secret Management

  • Rollouts and rollbacks

    Kubernetes Architecture & Components

The Kubernetes architecture is based on a master-worker model, in which the master node manages the entire cluster and the worker nodes host the containers.

Master's components :

  1. API server:
    -The front end of the Kubernetes control plane.
    - API server serves as the gateway, which helps in orchestration at each stage
    - The API server is used as a tunnel to all other components of the cluster.

  2. scheduler :
    -Determines whether new containers should be deployed, and if so, where they should be placed.
    -watches API Server for new work tasks.

  3. controller-manager :
    **-**Is a daemon that runs the Kubernetes cluster using several controller functions.
    -Takes corrective steps to make sure that the current state is the same as the desired state.
    -It is the controller of controllers.
    -Watches the objects it manages in the cluster.

  4. etcd :

    -Is a Data Warehouse of the K8s Architecture.
    **-**Stores configuration data and information about the state of the cluster, ConfigMap, Secrets, etc

Worker's components:

  1. Kubelet :

    -Each compute node includes a kubelet, an agent that communicates with the control plane to ensure the containers in a pod are running.
    -When the control plane requires a specific action happen in a node, the kubelet receives the pod specifications through the API server and executes the action.
    -It then ensures the associated containers are healthy and running.

  2. Kube-proxy:
    -Each compute node contains a network proxy called a kube-proxy that facilitates Kubernetes networking services.

    -The kube-proxy runs on each node to ensure that services are available to external parties and deal with individual host subnetting.
    -It ensures each Pod gets a unique IP address.

  3. Pods :
    -A pod represents a single instance of an application.
    -Each pod is composed of a container or containers.
    -Pods run together on nodes, so they share content and storage and can reach other pods via localhost.
    -Pods can be replicated for scaling.

K8s Installation and Configuration

You will need a minimum of 2 instances for this to work.
One will be your Master and the other will be your Worker instance.

Thanks to Rushikesh Mashidkar who has created the easiest steps for the Installation and Configuration of K8s here:

Scripts/k8sss.sh at main · RishikeshOps/Scripts (github.com)

The Content from Above Link :

---------------------------------------- Kubeadm Installation ------------------------------------------ 

-------------------------------------- Both Master & Worker Node ---------------------------------------

sudo apt update -y
sudo apt install docker.io -y

sudo systemctl start docker
sudo systemctl enable docker

sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg

echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

sudo apt update -y
sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y

##To connect with cluster execute below commands on master node and worker node respectively
--------------------------------------------- Master Node -------------------------------------------------- 
sudo su
kubeadm init

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml

kubeadm token create --print-join-command


------------------------------------------- Worker Node ------------------------------------------------ 
sudo su
kubeadm reset pre-flight checks
-----> Paste the Join command on worker node and append `--v=5` at end

#To verify cluster connection  
---------------------------------------on Master Node-----------------------------------------

kubectl get nodes

Thank you for reading.

#trainwithshubham #K8s