#KubeWeek Day1 - Understanding Kubernetes- Architecture and Components, Installation and Configuration
What is Kubernetes?
Kubernetes is an open-source container orchestration platform. developed by Google.
Helps in managing containerized applications in different deployment environments(virtual, Cloud, Physical, Hybrid).
Provide features of High Availability, High Performance, Disaster Recovery etc.,
Kubernetes architecture
Kubernetes follows Master node architecture.
Master Node(Control Plane)
The master node manages to schedule the pod, monitor,re-schedule / restart the pod, and join a new node.
The Master node has four components. Let's understand step by step.
API server :
whenever the user wants to deploy the application on a cluster in Kubernetes needs to interact with the API server using some client. the client can be UI like Kubernetes dashboard on command tool like Kubectl.
So API server is like a cluster gateway from which it gets requests or queries about scheduling pods, deploying new applications, creating new services etc.,
So it works like when a user requests to schedule a new pod API server checks the request, validates it and forwards it to the scheduler.
Scheduler :
After validating the request from the API server, the request will go to the scheduler. The scheduler will check which worker node has well-available resources to run this pod. it checks the resources like CPU and RAM which are needed to run the pod. In short, it decides on which node the new pod should be scheduled.
Controller Manager:
The controller manager detects state changes in the cluster like pod crashes or dies so it will request the scheduler to reschedule those pods.
etcd:
etcd is the cluster brain. It stores information about cluster data. When the pod get died or is scheduled all this information is saved or updated in etcd cluster in a key-value store format. It stores only cluster data, not application data.
Worker Node(Data Plane)
Three services must install on the worker node to work the Kubernetes cluster function properly. Each node has multiple pods on it. The services or components of the worker node are as below:
Kubelet:
Kubelet is responsible for managing the pods on the nodes. So if the pod is not running or dies kubelet will take care of it.
KubeProxy:
It takes care of the networking part in Kubernetes. It can be allocating ips to pod for communication.
Container Runtime:
It runs a container. It is responsible for running a container.
First, need to install the container runtime service. we are using docker.
then we need to install kubelet because it interacts with the container and node.
Kubernetes Installation and Configuration :
Let's see how to install Kubernetes on AWS. We need to make a cluster so we will use kubeadm installation.
We will create two EC2 instances one is a Master and another is a worker.
For Master Node we need the:
t2.medium.
2-core CPU.
4GB RAM.
For Worker Node we need the:
- t2.micro
Launch Master Node Instance
Select Ubuntu AMI.
Select an instance type t2.medium.
Select keypair.
Allow HTTP/HTTPS ports.
Launch Worker Node Instance
Select Ubuntu AMI.
Select an instance type t2.micro.
Select keypair.
Allow HTTP/HTTPS ports.
Now we need to install docker on both the Master and Worker nodes.
sudo apt install docker.io -y
Now we have to start docker on both machines.
sudo systemctl start docker
sudo systemctl enable docker we need kubeadm
To set up Kubernetes we need kubeadm.
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
Update the package on both machines.
sudo apt update - Master node we need to install kubeadm
Now we will install kubeadm on Master Node and Worker Node.
sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y
Master node Configuration
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
With the help of the below command any worker node that has a token can join the cluster.
kubeadm token create --print-join-command
It will generate like below:
kubeadm join <x.x.x.x Private ip>:<Port No.> --token --discovery-token-ca-cert-hash
We need to allow a port in the security group that is mentioned in the above tokens.
Now we will go to the worker node.
Worker Node Configuration
sudo su
kubeadm reset pre-flight checks
-----> Paste the Join command on worker node with `--v=5`
Now run the token command:
kubeadm join <x.x.x.x Private ip>:<Port No.> --token --discovery-token-ca-cert-hash --v=5
Now run the below command on Master Node
kubectl get nodes
Thank you.
Parimal Pradhan
Connect me on
LinkedIn: linkedin.com/in/parimal-pradhan-b62021168
Hashnod: https://parimalpradhan.hashnode.dev/
#Kubernetes #Devops #Kubeweek #kubeweekchallenge