In our last post, I provided an overview of what we are trying to accomplish, so we will dive right into creating a single node Kubernetes cluster.
We are going to use Rancher RKE2 running on Ubuntu 20.04. I will admit that a lot of these choices are due to familiarity. There are a few other options for advanced users.
- For a multi-node Rancher RKE2 cluster, check out A Return of Sorts
- For a slightly more manual way, consider using kubeadm (I really liked this post)
We will need to start with a serviceable Ubuntu 20.04 machine. You can really install this on your hypervisor of choice. I would recommend giving your VM 4vCPUs, 12gb of RAM, and a 60GB root drive. Head over to ubuntu.com and grab a manual install of 20.04. The installation is fairly easy, enable SSH and give your VM a static IP address. (And comment if you get stuck and I will set up a tutorial).
Advanced Tip: For those that want to build a ubuntu 20.04 template using VMware customizations, check out this post at oxcrag.net
We should now have a running Ubuntu 20.04 VM that we can SSH to. I will be installing all of the client tools and configurations on this same VM.
Let’s update our VM and install some client tools:
# Update and reboot our server sudo apt update sudo apt upgrade -y reboot # install git sudo apt install git # install kubectl sudo snap install kubectl --classic
Installing RKE2
Up until now, I have been a little loose with the terms Rancher and RKE2. Rancher is a management platform that can install on any Kubernetes flavor and acts as a bit of a manager of managers. RKE2 is the Rancher Kubernetes Engine 2, which is a lightweight Kubernetes distro that is easy to install and work with.
Install RKE2 with:
sudo curl -sfL https://get.rke2.io |sudo INSTALL_RKE2_CHANNEL=v1.23 sh - ### ### sudo systemctl enable rke2-server.service sudo systemctl start rke2-server.service
Now let’s install and configure some client tools.
# Snag the configuration file mkdir .kube sudo cp /etc/rancher/rke2/rke2.yaml ~/.kube/config sudo chown ubuntu:ubuntu .kube -R # Test Kubectl kubectl get nodes NAME STATUS ROLES AGE VERSION ubuntutest Ready control-plane,etcd,master 15m v1.23.9+rke2r1
That’s it! We have a single node Kubernetes cluster!