Part III: Redemption — Return of the Orchestrator

Let’s Cut to the Chase

After the events that occurred in Part II, let’s not waste any time.

Let’s build this cluster.

Prerequisites

  • three servers running Ubuntu (version 22.04 was used in this document) with a minimum of 2 vCPUs and 2 GB RAM each. Instances used for this documentation were hosted on AWS.
  • an account with sudo access or root account access
  • time and patience

Installation Steps

Execute these commands on all servers — master and worker nodes.

sudo apt update && sudo apt upgrade -y

Kubernetes Container Network Prep

Create the containerd.conf file.

sudo vi /etc/modules-load.d/containerd.conf

Add these lines to the file.

overlay
br_netfilter

Save and close the file.

Execute these commands to add these two modules to the kernel.

sudo modprobe overlay
sudo modprobe br_netfilter

Create the 99-kubernetes-cri.conf file.

sudo vi /etc/sysctl.d/99-kubernetes-cri.conf

Add these lines to the file.

net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1

Save and close the file.

Apply these settings.

sudo sysctl --system

Install the container runtime (containerd)

sudo apt update && sudo apt install -y containerd

Create the containerd configuration file

sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml

Recycle the containerd to load the new configuration file

sudo systemctl restart containerd

Disable system swap

sudo -i
swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
exit

Install dependency packages, add the GPG key, and Kubernetes apt repo.

apt-get update && sudo apt-get install -y apt-transport-https curlcurl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

Apply any remaining updates

sudo apt update

Install Kubernetes components

sudo apt install -y kubelet=1.21.0-00 kubeadm=1.21.0-00 kubectl=1.21.0-00sudo apt-mark hold kubelet kubeadm kubectl

Start the Cluster

Execute these commands only on the Master Node.

Initialize the cluster

sudo kubeadm init --pod-network-cidr 192.168.0.0/16 --kubernetes-version 1.21.0
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

The cluster is now running.

Install Calico — container networking code

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

Wait several minutes then check the cluster.

kubectl get nodes

Make a note of the kubeadm join command that is listed at the end of the kubeadm init command’s output, which looks like this.

kubeadm join 172.31.0.37:6443 --token btiwv9.7t0yxbyyy5mqdoko --discovery-token-ca-cert-hash sha256:4c619ea9470ac72c36d2cca284469fff5dc25a791d5d0e7c79c50ae726dc23cd

It will be needed to join worker nodes to the cluster.

If necessary, create a new token to get the command needed to add the worker nodes.

kubeadm token create --print-join-command

List the nodes and all pod namespaces

kubectl get nodes
kubectl get pods --all-namespaces
It’s Alive!!

Add the Workers to the Cluster

Run the kubeadm join command on the worker nodes.

kubeadm join <ip-address>:6443\
--token=<token-from-step-2> \
--discovery-token-ca-cert-hash sha256:<ca-hash-from-step-1>

On the master node, check the status of the cluster.

kubectl get nodes

The two worker nodes are now part of the cluster.

Finally!

The cluster is up and running.

Initially, the above steps were implemented without explicitly stating the version, i.e.

sudo apt install -y kubeadm kubelet kubectl

The same problems appeared.

The biggest difference about the above instructions versus those in Part II was installing Kubernetes version 1.12.0.

sudo apt install -y kubelet=1.21.0-00 kubeadm=1.21.0-00 kubectl=1.21.0-00

In conclusion, this author suggests the reader should only use the current version of Kubernetes (at the time of this writing, June 19, 2022) if he or she needs to push their personal level of sanity into unknown territory.

If using the current version, ensure emergency services are standing by. #911

Moving On

Victory is now in hard so the journey continues.

Coming soon…

Part IV: Cluster Management

Reference:
“Kubernetes by Doing”

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store