# A Step-by-Step Guide to Kubeadm Installation on Both Master and Worker Nodes

Introduction: Kubeadm is a popular tool for setting up a Kubernetes cluster quickly and easily. In this guide, we will walk you through the installation process of Kubeadm on both master and worker nodes to create your own Kubernetes cluster. By following these steps, you'll be able to deploy and manage containerized applications efficiently. Let's dive into the installation process.

**Prerequisites:** Before you begin, make sure you have two Ubuntu-based machines, one designated as the master node and the other as the worker node. Ensure that you have root access to both nodes.

**Installing Kubeadm on Both Master and Worker Nodes:** To begin, follow these steps on both your master and worker nodes.

**Step 1: Update and Install Docker**

```shell
sudo su
apt update -y
apt install docker.io -y

systemctl start docker
systemctl enable docker
```

**Step 2: Add Kubernetes Repository and Install Kubeadm**

```shell
curl -fsSL "https://packages.cloud.google.com/apt/doc/apt-key.gpg" | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg
echo 'deb https://packages.cloud.google.com/apt kubernetes-xenial main' > /etc/apt/sources.list.d/kubernetes.list

apt update -y
apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y
```

**Master Node Setup:**

**Step 3: Initialize Kubernetes on the Master Node**

```shell
sudo su
kubeadm init
```

**Step 4: Configure Kubeconfig** To start using your cluster, you need to configure your kubeconfig file.

```shell
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
```

**Step 5: Deploy a Pod Network**

```shell
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
```

**Step 6: Generate Join Command**

```shell
kubeadm token create --print-join-command
```

**Worker Node Setup:**

**Step 7: Reset and Join Worker Node**

```shell
sudo su
kubeadm reset pre-flight checks
# Paste the Join command obtained from the master node and append `--v=5` at the end
```

**Step 8: Verify Cluster Connection** To ensure that your cluster is up and running, run the following command on the master node:

```shell
kubectl get nodes
```

Conclusion: Congratulations! You've successfully set up a Kubernetes cluster using Kubeadm on both the master and worker nodes. Now you can start deploying and managing your containerized applications. Kubernetes offers a powerful platform for orchestration and scaling, making it easier to manage container workloads in a production environment. Happy containerization!
