Kubernetes HandsOn Project
Kubernetes HandsOn Project
Kubernetes HandsOn Project
Prerequisites:- ubuntu:latest
1 - Control plane t2.medium and above
2 - Worker nodes t2.micro and above
• Use 'hostnamectl' command to change the hostname of both the server and worker
nodes
hostnamectl set-hostname kubeserver = controlplane
• To apply the changes, please log out of and then log back into the instances.
sudo -i
wget https://github.com/containerd/containerd/releases/download/v1.7.5/containerd-1.7.5-linux-amd64.tar.gz
systemctl daemon-reload
systemctl enable --now containerd
wget https://github.com/opencontainers/runc/releases/download/v1.1.9/runc.amd64
install -m 755 runc.amd64 /usr/local/sbin/runc
wget https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-
v1.3.0.tgz
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.3.0.tgz
• Verify that the br_netfilter, overlay modules are loaded by running the following
commands:
lsmod | grep br_netfilter
lsmod | grep overlay
Installing kubeadm:
Below steps are common for both master server and worker nodes.
1. Update the APT package index and install the necessary packages to enable the use of
the Kubernetes APT repository.
sudo apt-get update
apt-get update && sudo apt-get install -y apt-transport-https curl
2. Download the public signing key for the Kubernetes package repositories
mkdir -p /etc/apt/keyrings/
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --
dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
4. Update the apt package index, install kubelet, kubeadm and kubectl
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
5. apt-mark hold will prevent the package from being automatically upgraded or
removed.
apt-mark hold kubelet kubeadm kubectl containerd
From here below steps are only for master server. make sure you execute them only
on master.
1. downloading component images on master.
kubeadm config images pull
• If you have plans to upgrade this single control-plane kubeadm cluster to high
availability you should specify the --control-plane-endpoint to set the shared endpoint
for all control-plane nodes. Such an endpoint can be either a DNS name or an IP
address of a load-balancer.
kubeadm init
Note: Copy the join token and save it
kubeadm join 172.31.24.155:6443 --token yo1pa1.zky7ws22p1kk1e22 \
--discovery-token-ca-cert-hash
sha256:86ac30b64f12f6f24b10ac36bb9a881ee5c813321d894871507d90501c037871
3. To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
• You will notice from the previous command, that all the pods are running except one:
‘coredns’.
• For resolving this we will install a # pod network.
8. To verify the worker node status, run 'kubectl get nodes' on the control-plane
kubectl get nodes