Kubernetes Cluster using Kubeadm

We are using AWS Cloud for creating a Kubernetes cluster using kubeadm - one master node and one worker node.

For this setup, we need two EC2 instances for each node.

Min requirement:

  • Master node: 4 GB RAM and 2 vCPU type instance

  • Worker node: t2.micro instance type is fine.


Create a Master Node

# update the system
sudo apt update -y

# install docker  
sudo apt install docker.io -y

# start docker
sudo systemctl start docker

# enable by-default boot-up 
sudo systemctl enable docker

# download the kubernetes keys from google
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg

# place the keys under /etc/apt/source.list.d/kubernetes.list
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 system
sudo apt update -y

# install the kubeadm, kubectl and kubelet
sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y

# start the kubeadm service
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

# create the token for workernode to join, copy it and run this commad on worker node
kubeadm token create --print-join-command

# After worker node is created (check:Create a Worker Node section) and joined using above command, now check the connected nodes on master node
kubectl get nodes

Create a Worker Node

# update the system
sudo apt update -y

# install docker  
sudo apt install docker.io -y

# start docker
sudo systemctl start docker

# enable by-default boot-up 
sudo systemctl enable docker

# download the kubernetes keys from google
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg

# place the keys under /etc/apt/source.list.d/kubernetes.list
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 system
sudo apt update -y

# install the kubeadm kubelet
sudo apt install kubeadm=1.20.0-00 kubelet=1.20.0-00 -y

# reset the pre-flight checks
sudo su
kubeadm reset pre-flight checks

# now paste the join command, which was generated on master node
-----> Paste the Join command on worker node with `--v=5`

That is! A simple Kubernetes cluster using Kubeadm is created. :)

Keep learning :)