Kubernetes Architecture and Components, Kubernetes Installation and Configuration
What is Kubernetes?
Kubernetes is an open-source Container Management tool that automates Container deployment, container scaling & load balancing.
It schedules, runs, and manages isolated containers which are running on Virtual/Physical/Cloud Machines.
Kubernetes Installations tool
Minikube
Kubeadm
Architecture of Kubernetes?
Master node
Kubernetes designates one or more of these as masters and all others as workers.
The master is now going to run a set of K8s processes. These processes will ensure the smooth functioning of the cluster. These processes are called "Control Plane".
Can be a Multi-master for high availability.
The master runs the control plane to run the cluster smoothly.
Component of Control Plane (Master node)
1.Kube-API server
2.ETCD Cluster
3.Kube-Scheduler
4.Kube-Controller Manager
**Kube-API server
This API server interacts directly with the user (i.e. we apply .yml or json manifest to kube-Apiserver)
**ETCD Cluster
Stores metadata and status of Cluster.
ETCD is a consistent and high-available store (Key-value store)
Source of touch for cluster state (info about the state of the cluster)
**Kube-Scheduler
Responsible for scheduling the pods on the nodes.
It just decides which pod to place on which node band on the CPU, RAM, and resources on the Node.
Kubelet places the nodes after the scheduler decides.
The right container/pod is sent to the right snip/node.
**Kube-Controller Manager
Continuously monitor various components of the cluster and works toward managing/restoring to the desired state.
**Node Controller
Communicates with kube Apiserver and manages nodes. [Every 5 seconds]
Checks again for 40 seconds then mark as "unreachable"
After 5 minutes it replaces
**Replication Controller
Responsible for monitoring the status of the replica set.
Ensures that desired no. of Pods are available at the required time.
**Kubelet
The agent running on the node.
Listens to Kubernetes master (eg:- Pod creation request)
Use Port 10255
Send success/fail reports to master
Kube-Proxy
Assign IP to each Pod.
It is required to assign IP addresses to pods(dynamic).
Kube-Proxy runs on each node & this makes sure that each pod gets its own unique IP address.
These 3 components collectively consist of "node".
*POD
The smallest unit in Kubernetes.
POD is a group of one or more containers that are deployed together on the same host.
A Cluster is a group of nodes.
A Cluster has at least one worker node and a master node.
In Kubernetes, the control unit is the pod, not the containers.
Consist of one or more tightly coupled containers.
POD runs on a node, which is controlled by the master.
Kubernetes only knows about PODS (does not know about individuals container).
Cannot start containers without a POD.
One Pod usually contains one container.
*Replica sets
To prevent users from losing access to the app, the replication controller gives high availabilities.
Help in load balancing and scaling.
*Deployment
Pods deploy single instances of an application.
Deployment allows updating the pod's infrastructure with Replicas, Rolling updates, etc.
*Services
Helps us connect our applications with other applications/databases etc.
Container Engine (Docker)
Works with Kubelet
Pulling images
Start/Stop Containers
Exposing containers on ports specified in the manifest
Kubectl
A command line tool used to communicate with a Kubernetes cluster's control plane.
Kubectl apply.
Creates the live object for the configuration
Kubernetes Installations and Configurations
Login into AWS account-> Launch 2 Instances--> Ubuntu 22.04 LTS (t2.medium) Master must have 2 VCPUs and 4GB RAM and for Worker Node instance type (t2.micro).
Commands Common for Master and Worker Node
sudo apt-get update
install docker on all 2 instances
sudo apt install docker.io -y
Check, whether docker is installed or not
docker --version
Check, whether docker is installed or not
docker --version
sudo systemctl start docker sudo systemctl enable docker sudo systemctl status docker
Install kubeadm on both machines
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
The next step is to configure the 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
The last step is to configure the Worker Node
Firstly add an inbound rule in Master Node add Port No 6443
sudo su kubeadm reset pre-flight checks
Paste the Join command on worker node with --v=5
Verify the Cluster Finally, run the following command on the master node to verify that the cluster is up and running
kubectl get nodes