Kubernetes Lab Install with Ubuntu 22.04
Prior to getting started make sure that you have KVM installed and Create Network Bridge.
Create VMs for the Kubernetes Cluster
The first thing we need to do is create our virtual machines. For this lab, we will create 3 virtual machines. One for the controller and 2 workers.
It will make things easier to set static IPs during Ubuntu Server installation. Make sure you choose IPs that are not in use and are part of your network.
Configure all nodes
We need to run some configuration on each of the nodes. Make sure to run all the following commands on each node in the cluster.
/etc/hosts file and add the following lines: (updating for your actual IPs from earlier)
Save the file and exit.
Run the following commands:
Load Kernel Modules
Run these commands to load the required kernel modules:
Load the changes:
To install containerd prerequisites:
Enable Docker Repository
We need to configure containerd to start automatically:
Restart and enable the service:
Get ready to install Kubernetes
First, add the apt repository for Kubernetes.
Next, install kubectl, kubeadm and kubelet.
Kubernetes Controller Configuration
This section is only to be completed on the kubernetes controller node.
Now we need to initialize the kubernetes cluster.
You will see output with the next commands to run.
Run the following commands to manage the node from a regular user.
Run the following commands to view the cluster status.
Join Worker Nodes to the Cluster
The output of the kubeadm command will have a line that you can copy and paste to run on your worker nodes. This will join them to the cluster.
Run the line shown in your output on each worker node.
Finishing up cluster configuration
Back on our controller node run the following command:
Install Calico Pod Network
In order for our nodes to talk to each other, we need to install Calico Pod Network Add-on:
After some time your nodes should all show as running:
Save yourself some time and create snapshots of all three virtual machines.
Since this is a lab environment, our Kubernetes installation will most assuradly get messed up.
Run the following commands on you vm host:
When things get hosed run these commands to restore the snapshots: