Here is a step-by-step process for installing a Kubernetes HA cluster using Kubeadm:
Prerequisites
- Three or more Linux servers running Ubuntu 20.04 or later, with at least 2GB of RAM and 2 CPUs each.
- Ensure that each node has a unique hostname, a static IP address and that the nodes can communicate with each other over the network.
Get ready to revolutionize your software development and deployment process with our Kubernetes course — the industry-leading container orchestration system used by top companies worldwide. Enroll now and become a master of managing containerized applications with ease!
Kubernetes with HELM: Kubernetes for Absolute Beginners CKA
Certified Kubernetes Application Developer | CKAD Exam 2023
Step 1: Install Docker and Kubernetes on each node
- Install Docker on each node by running the following commands:
sudo apt-get update
sudo apt-get install -y docker.io
sudo systemctl enable docker
- Install Kubernetes on each node by running the following commands:
sudo apt-get update
sudo apt-get install -y apt-transport-https curl
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
Step 2: Initialize the control plane node
- Choose one of the nodes to be the control plane node and run the following command to initialize it:
sudo kubeadm init --control-plane-endpoint "LOAD_BALANCER_DNS:LOAD_BALANCER_PORT" --upload-certs
- Replace LOAD_BALANCER_DNS with the DNS name or IP address of the load balancer that will be used to access the control plane, and replace LOAD_BALANCER_PORT with the port number on which the load balancer will listen for traffic.
- After the initialization process is complete, you will be provided with a command to run on the other nodes to join the cluster.
Step 3: Join the worker nodes to the cluster
- On each worker node, run the command that was provided at the end of the initialization process on the control plane node, for example:
sudo kubeadm join CONTROL_PLANE_ENDPOINT --token TOKEN --discovery-token-ca-cert-hash HASH
- Replace CONTROL_PLANE_ENDPOINT with the IP address or DNS name of the control plane node, and replace TOKEN and HASH with the values that were provided during the initialization process.
Step 4: Install the network plugin
- Install a network plugin to enable communication between the nodes in the cluster. We will use Calico in this example:
kubectl create -f https://docs.projectcalico.org/v3.19/manifests/calico.yaml
Step 5: Verify the cluster status
- Run the following command on the control plane node to verify the status of the cluster:
kubectl get nodes
- The output should show all nodes in the cluster with a status of `Ready`.
Congratulations! You have now set up a Kubernetes HA cluster using Kubeadm.