Deploy Kubernetes Cluster
The first thing we have to do is initialize a cluster.On Master Node execute the following command.
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
Where “–pod-network-cidr” defines the IP address range that is assigned to individual pods within the cluster.
Network Used
In this tutorial, we use the Calico virtual network. If 192.168.0.0/16 is already in use within your network or you want to use custom virtual network, you must select a different pod network CIDR, replacing 192.168.0.0/16 in the above command You can choose it on official Kubernetes web site. After executing the command we will see that our Kubernetes control plane has initialized successfully.
Also, we need to enable for auto start service after rebooting and check the kubelet status to make sure that the service status is Active.
sudo systemctl enable kubelet && sudo systemctl status kubelet
For managing the Kubernetes cluster we need to create a folder to store kubernetes configuration files, copy already generated (from previous command) config file, and then change permissions.For that, we need to execute the following commands.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/
.kube/config && sudo chown $(id -u):$(id -g) $HOME/.kube/config
- mkdir: create new folder
- cp: copy configuration file to the folder from the previous command.
- chown $(id -u):$(id -g): set the user and group ownership to the current user.
After adding the configuration file we need to set up the network pod. Pods in the cluster are connected to each other via Pod Network.For this scenario, we use the Calico pod network. Use the following commands to download and install Calico the Pod Network.
If you use a different virtual network, please change “https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/calico.yaml -O” and “calico. yaml” in the second command to yours.
curl https://raw.githubusercontent.com/projectcalico
/calico/v3.25.1/manifests/calico.yaml -O
sudo kubectl apply -f calico.yaml
After applying the configuration file from the previous command we can check the status of our node. To verify status of our node, we will run the following command on Master Node.
sudo kubectl get nodes
Also, let’s confirm that each service has a running status.
sudo kubectl get pods --all-namespaces
As we can see the status of our Master Node is Ready and all our services have running status.
How To Deploy Kubernetes on CentOS?
Kubernetes cluster is a set of nodes that execute applications within containers. Clusters consist of a master node and several worker nodes. These nodes could be physical computers or virtual machines. It depends on the configuration of the cluster. The master node manages and coordinates the worker node. The worker nodes are responsible for executing tasks and running containerized applications by the master node’s directions.
steps needed to deploy Kubernetes on CentOS. We will install container runtime, install Kubernetes on CentOS, create Kubernetes Cluster, and connect Worker nodes to the cluster.
Contact Us