kubeweek Day1 : Kubernetes Architecture and Components, Kubernetes installation and configuration.
What is Kubernetes?
Kubernetes is a powerful tool that helps you manage your applications in a reliable and scalable way. At its core, Kubernetes is a container orchestration system. That means it helps you manage and deploy your containers - which are like lightweight, self-contained versions of your applications.
So what does the architecture of Kubernetes look like?
At a high level, there are two main components: the master node and the worker nodes. The master node is responsible for managing the overall state of your cluster, while the worker nodes are where your containers actually run.
The master node has a few different components that work together to manage your cluster. These include:
The API server, which exposes an API that you can use to interact with your cluster
The etcd database, which stores the configuration data for your cluster
The controller manager, which watches the state of your cluster and makes changes as necessary
The scheduler, which decides where to place your containers based on resource constraints and other factors
On the worker nodes, there are a few key components as well:
The kubelet, which runs on each node and communicates with the master node to get instructions on what containers to run
The container runtime, which actually runs your containers (like Docker or containerd)
The kube-proxy, which handles network traffic between your containers
Installing and Configuring Kubernetes
Please follow the below steps to configure the lab Master machine:
STEP 1: On Master Node Only:
- Kindly execute the below commands to Configure Docker Daemon:
sudo su –
sudo wget https://raw.githubusercontent.com/lerndevops/labs/master/kubernetes/0-install/daemon.json -P /etc/docker
sudo systemctl restart docker.service
sudo service docker status
- Initialize kubernetes Master Node by running the following command:
sudo kubeadm init
- To fix the problem of "The connection to the server localhost:8080 was refused - did you specify the right host or port?", please run the below-mentioned commands:
sudo mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown (id -g) $HOME/.kube/config
- Install networking driver -- Weave/flannel/canal/calico etc. by executing the following command:
sudo kubectl apply -f
https://raw.githubusercontent.com/projectcalico/calico/v3.24.1/manifests/calico.yaml
- Validate using the command "kubectl get nodes"
Step 2: ON ALL Worker Nodes
- Configure Docker Daemon on all worker nodes by executing the below commands:
sudo su -
hostname WORKER1
sudo su -sudo wget https://raw.githubusercontent.com/lerndevops/labs/master/kubernetes/0-install/daemon.json -P /etc/docker
sudo systemctl restart docker.service
sudo service docker status
Run Below on Master Node to get join token and copy the kubeadm join token from master & run it on all nodes with the command "sudo kubeadm join <master-node-ip>:6443 --token mks3y2.v03tyyru0gy12mbt --discovery-token-ca-cert-hash sha256:3de23d42c7002be0893339fbe558ee75e14399e11f22e3f0b34351077b7c4b56"
Validate on master node using the commands "kubectl get nodes" and "kubectl get nodes -o wide"
If nodes are with status as NotReady, then delete the node and join it again in the cluster by executing the below steps:
On Master Node:
kubectl delete node nodename
kubectl get nodes
On the same Worker node that we have to delete:
kubeadm reset --force
On master Node: generate the token again, execute the below command:
sudo kubeadm token create --print-join-command
Copy the token
On Worker Node: Copy the token, the node will join the master node
On Master Node:
kubectl get nodes
API Server,etcd, scheduler,controller-manager and kubelet
Kubernetes is a system for managing containerized applications, which can run on one or more computers. It provides a way to automate the deployment, scaling, and management of these applications. In order to accomplish this, Kubernetes uses several different software components, each with its own specific role to play.
Kubernetes API server:-
This component acts as the central control point for the entire Kubernetes cluster. It receives requests from users or other systems and then passes those requests on to the appropriate component in the cluster to be executed. For example, if someone wanted to deploy a new containerized application, they would send a request to the API server to do so.
etcd:-
Think of etcd as a kind of "brain" for the Kubernetes cluster. It stores all of the configuration data and state information about the cluster. This includes things like what applications are running, how many instances of each application should be running, and which nodes in the cluster are available to run those applications. Whenever a change is made to the cluster configuration, such as adding or removing an application, that change is recorded in etcd.
Scheduler:-
This component is responsible for deciding which nodes in the cluster should run which instances of each application. When a new application needs to be launched, the scheduler looks at the resource requirements of that application and the available resources on each node in the cluster, and then assigns the application to the node that can best meet its requirements.
Controller-manager:-
This component is responsible for monitoring the state of the cluster and taking action if anything goes wrong. For example, if a node in the cluster fails, the controller manager will notice this and take steps to replace that node with a new one.
kubelet:-
This component runs on each individual node in the cluster and is responsible for managing the containers and pods running on that node. It communicates with the API server to receive instructions about what containers and pods should be running on the node and then makes sure that those containers and pods are actually launched and running correctly.
In this article, we explored the basics of Kubernetes architecture, installation, and configuration. We discussed how Kubernetes is designed to manage containerized applications and the components that make up a Kubernetes cluster, including the control plane and worker nodes. We also walked through the steps to set up and configure a basic Kubernetes cluster using kubeadm.
Thanks and please follow for more blogs Yashwant Chaudhari