Kubernetes

Install kubernetes cluster using kubeadm

Hello everyone! 👋 Welcome to our step-by-step guide on using kubeadm to install Kubernetes. It’s worth noting that this method is more of a learning tool and isn’t recommended for a production environment. Let’s get into it!

First up, let’s prep our machine for this Kubernetes journey, ensuring we’re all set to hop into all nodes.

Step 1: Create a configuration file for containerd. Here’s the magic code you need:

cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF

Step 2: Let’s get those modules loaded:

sudo modprobe overlay
sudo modprobe br_netfilter

Step 3: Next, we’ll set up system configurations for Kubernetes networking:

cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF

Apply these settings with sudo sysctl --system.

Great job so far! 😎 Now we’re onto the next steps.

Step 4: Install containerd:

sudo apt-get update && sudo apt-get install -y containerd.io

Step 5: Create a default configuration file for containerd:

sudo mkdir -p /etc/containerd

And then generate a default containerd configuration:

sudo containerd config default | sudo tee /etc/containerd/config.toml

Restart containerd with sudo systemctl restart containerd and verify it’s running with sudo systemctl status containerd.

Step 6: Next, disable swap: sudo swapoff -a.

Time for some kubeadm and Kubernetes package installs.

Step 7: Install some needed packages:

sudo apt-get update && sudo apt-get install -y apt-transport-https curl

Step 8: Download and add the GPG key:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Step 9: Time to add Kubernetes to your repository list:

cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

Step 10: Refresh package listings: sudo apt-get update.

Now, we’re ready to install the Kubernetes packages using kubeadm.

Step 11: Here’s how to install Kubernetes packages with kubeadm:

sudo apt-get install -y kubelet=1.27.0-00 kubeadm=1.27.0-00 kubectl=1.27.0-00

We want to keep things stable, so turn off automatic updates: sudo apt-mark hold kubelet kubeadm kubectl.

Step 12: Time to initialize the cluster with kubeadm. Do this on the control plane node:

sudo kubeadm init --pod-network-cidr 192.168.0.0/16 --kubernetes-version 1.27.0

Step 13: Set up kubectl access:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Does everything look good? Let’s check: kubectl get nodes.

Step 14: Time to install Calico Networking on the control plane node:

kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml

Check the status of the control plane node: kubectl get nodes.

Alright, almost there!

Step 15: Let’s join the worker nodes to the cluster. Create a token and copy the kubeadm join command:

kubeadm token create --print-join-command

Paste the kubeadm join command into the worker nodes to join the cluster:

sudo kubeadm join 10.0.1.101:6443 --token 71u8rt.fs4ue7o9gcer84jr --discovery-token-ca-cert-hash sha256:23f2db254daa8fdde50e2443f77633e7b09e34d0c5438be36204f81a90c87bbc

And finally, check the cluster status back on the control plane node: kubectl get nodes.

And that’s it! Congratulations, you’ve successfully installed Kubernetes using kubeadm! Great job! 🎉 Please remember, this method is not recommended for a production environment, but it’s an excellent way to learn!

Akhmad Fakhoni Listiyan Dede

Share
Published by
Akhmad Fakhoni Listiyan Dede

Recent Posts

Mengimplementasikan AI untuk Melakukan Review pada Pull Request Github

Halo semua Github memiliki fitur terkait Pull Request yang cukup luar biasa, yaitu dapat melakukan…

7 months ago

Meningkatkan Efisiensi Memory Proxmox Lebih dari 20%

Proxmox adalah hypervisor yang populer digunakan karena penggunaannya yang cukup simpel jika dibandingkan dengan hypervisor…

4 years ago

Longhorn Failed Upgrade from v0.8.1 to v1.0.0 caused by pv created before v0.6.2

This post is mirror of https://forums.rancher.com/t/failed-upgrade-from-v0-8-1-to-v1-0-0-caused-by-pv-created-before-v0-6-2/17586 I scale down all pods that has vpc to…

5 years ago

Cara Setup Network Ubuntu Server 18.04 pada Proxmox

Ubuntu Konfigurasi network pada Ubuntu Server 18.04 berbeda dengan ubuntu versi sebelumnya. Versi sebelumnya menggunakan…

5 years ago

VSCode Terminal Font Fix on MacOS

For detailed problems, see https://notulensiku.com/2019/02/fix-integrated-terminal-font-vscode/ To solve on mac, you need to install powerline fonts…

5 years ago

Enable Forward Secrecy pada Apache

Untuk mengaktifkan Forward Secrecy pada web browser Apache, versi minimum yang dibutuhkan adalah: OpenSSL 1.0.1c+Apache…

6 years ago