How to Install Kubernetes on Debian

How to Install Kubernetes on Debian

- 5 mins

Before Installation of K8s?

K8s Installation

:one: Install Containerd Run time on All Nodes

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

modprobe overlay 
modprobe br_netfilter

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

k8s

:two: We need to install containerd and settingup contianerd for k8s.

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" |sudo tee /etc/apt/sources.list.d/docker.list
apt update
apt install containerd
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&1
vi /etc/containerd/config.toml
systemctl restart containerd
systemctl enable containerd

k8s

:three: Install curl for both nodes.

apt install curl -y

:four: Add the Kubernetes signing key on both the nodes.

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

:five: Add Kubernetes Repository on both the nodes.

apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"

k8s

apt update

:six: Install Kubeadm and some k8s tools on both the nodes.

apt update
apt install kubelet kubeadm kubectl -y
apt-mark hold kubelet kubeadm kubectl

k8s

Install Kubernetes Cluster with Kubeadm

:one: We need to disable SWAP memory (SWAP RAM), on both the nodes as Kubernetes does not perform properly on systems that is using swap memory.

swapoff -a

:two: Before Initialize K8s I would like to change hostname of VMs for better understanding

hostnamectl set-hostname "k8s-master.local"      // Run on master node
hostnamectl set-hostname "k8s-worker01.local"    // Run on 1st worker node
-IP-  k8s-master.local     k8s-master
-IP-  k8s-worker01.local   k8s-worker01

k8s

:three: Initialize K8s in Master-node i.e master-node

kubeadm init --control-plane-endpoint=k8s-master

k8s

$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubeadm join k8s-master:6443 --token r6yvos.wqdlt5dkmrw2kx0f \
        --discovery-token-ca-cert-hash sha256:1fad2cd211a21a7a49fb569518ace419c4aa292790d0754c5677c67acd552116 
$ kubectl get nodes
$ kubectl cluster-info

k8s :boom: :boom: :boom: :boom: :boom: :boom: :boom:

:four: Check the nodes status by running following command from master node,

kubectl get nodes

k8s

:five: Setup Pod Network Using Calico

kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/calico.yaml
kubectl get pods -n kube-system

k8s

kubectl get nodes

k8s

:arrow_forward: :arrow_forward: :arrow_forward: You are ready for deploy applications. Enjoy with your Kubernetes Cluster



:blush: :star: :boom: :fire: :+1: :eyes: :metal:


Guneycan Sanli.


Guneycan Sanli

Guneycan Sanli

A person who like learning, music, travelling and sports.

comments powered by Disqus