Deploy a Kubernetes Desktop Cluster with Ubuntu Multipass – InApps Technology is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn Deploy a Kubernetes Desktop Cluster with Ubuntu Multipass – InApps Technology in today’s post !
Read more about Deploy a Kubernetes Desktop Cluster with Ubuntu Multipass – InApps Technology at Wikipedia
You can find content about Deploy a Kubernetes Desktop Cluster with Ubuntu Multipass – InApps Technology from the Wikipedia website
Canonical’s Multipass is an incredibly easy tool for the deploying of virtual machines. It’s quite unlike VirtualBox or VMware, in that it’s a command-line only tool and you’re limited to spinning up only Ubuntu-based images as virtual machines. However, what it lacks in flexibility, it makes up for in ease of use.
With this tool, you can deploy a Kubernetes cluster to make your development process a bit easier. You certainly won’t be using Multipass as a production environment, but for anyone that prefers development on a single machine, you cannot beat this platform.
I want to walk you through the process of deploying a Kubernetes cluster using Multipass. I’ll be demonstrating on System76’s very own Pop!_OS, an OS tweaked for science work built upon Ubuntu. If Pop!_OS isn’t your jam, you can install Multipass on any Linux distribution that supports snap packages. You can also install Multipass on macOS and Windows, by downloading either the .exe or .pkg files from the Multipass downloads page. Once you have Multipass installed, the instructions for usage will be similar, regardless of platform.
Before we install Multipass, let’s make sure to update and upgrade our system (for good measure). To do this, log in, open a terminal window, and issue the following two commands:
sudo apt-get update
sudo apt-get upgrade -y
Do remember, if the kernel gets upgraded, you’ll need to reboot the system, in order for the changes to take effect. So, if this is a production machine, you’ll want to run the upgrade at a time when a reboot is feasible.
With the update/upgrade out of the way, let’s install Multipass. To do this, we’ll use the snap command like so:
sudo snap install multipass --classic --stable
When the command completes, Multipass is installed and ready to deploy your first virtual machine.
Launching Your Virtual Machines
We’re going to launch three virtual machines for our Kubernetes cluster. I’m going to launch some bare minimum VMs, but you can bump up the specs as you see fit. My VMs will each have a unique name, 2 CPUs, 1024MB of memory, and 10GB of storage. Remember, you can alter that configuration as needed.
The first VM will be the Kubernetes controller. To launch this, the command would be:
multipass launch --name k3s-controller --cpus 2 --mem 1024M --disk 10G
Depending on your network connection (and the speed of your hosting machine), this will take anywhere between 1-5 minutes.
Next, we’ll launch our first node with the command:
multipass launch --name k3s-node1 --cpus 2 --mem 1024M --disk 10G
Finally, we’ll launch our second node with the command:
multipass launch --name k3s-node2 --cpus 2 --mem 1024M --disk 10G
To verify that the virtual machines successfully launched, issue the command:
You should see all three VMs in place (Figure 1).
Installing the Necessary Software
At this point, things should start looking familiar (if you’ve ever deployed a Kubernetes cluster). We’re going to access the controller and install Docker and Kubernetes. Access the controller with the command:
multipass shell k3s-controller
Update apt with the command:
sudo apt-get update
Now we can install Docker with the command:
sudo apt-get install docker.io -y
Start and enable the Docker service with the commands:
sudo systemctl start docker
sudo systemctl enable docker
Now, add the current user to the docker group with the command:
sudo usermod -aG docker $USER
Make the system aware of the new group addition with the command:
It’s now time to install Kubernetes. We first must add the repository key and the repository with the following commands:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
Finally, we can install all of the necessary Kubernetes tools with the command:
sudo apt-get install kubeadm kubelet kubectl -y
Open a second terminal window and issue the command:
Take note of the IP addresses assigned to the virtual machines.
Back at the k3s-controller, issue the command:
sudo nano /etc/hosts
In that file, add the following:
Make sure to adjust the IP addresses according to your multipass list command output.
Turn off swap with the command:
sudo swapoff -a
Now it’s time to deploy Kubernetes on the controller with the command:
sudo kubeadm init --pod-network-cidr=10.171.55.97/16
Again, make sure to adjust the IP address above to that of your k3s-controller.
This could take some time. While it finishes, gain access to node1 and node2 and install both Docker and Kubernetes in the same fashion you did with the controller. Also, make sure to edit the /etc/hosts files on both machines as well.
Once you’ve taken care of the nodes, go back to the controller and you should see the kubeadm join command, which should look like:
sudo kubeadm join 10.171.55.97:6443 –token 6latiw.pjq5e1qrgwabrhc8 –discovery-token-ca-cert-hash sha256:a8ebefbc70706dd31d016ea215b947e56baea354f0d1d4927926af2ec564ea44
Copy that join command.
Access node1 with the command:
multipass shell k3s-node1
Connect node1 with the kubernetes join command. Once that’s taken care of, exit out of node1 and access node2 with the command:
multipass shell k3s-node2
Once inside node2, run the kubernetes join command as you did in node1. When that completes, exit out of node2 with the exit command.
The final steps are taken back at the controller. If you’re not still within the controller, gain access with the command:
multipass shell k3s-controller
Once inside, the first thing to do is to create a directory for the cluster with the command:
mkdir -p $HOME/.kube
Next, copy the config file into this directory with the command:
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
Change the config file’s permissions with the command:
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Finally, deploy a pod network to the cluster with the command:
sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
Checking the Status of Your Cluster
At this point, both our nodes have joined the cluster. But how do we know for sure? On the controller, issue the command:
kubectl get nodes
You should see both nodes have joined the cluster and are listed as Ready (Figure 2).
And there you have it, your Multipass-deployed Kubernetes cluster is ready for you to start developing.
Feature image by Nareeta Martin on Unsplash.
At this time, InApps Technology does not allow comments directly on this website. We invite all readers who wish to discuss a story to visit us on Twitter or Facebook. We also welcome your news tips and feedback via email: [email protected].
InApps Technology is a wholly owned subsidiary of Insight Partners, an investor in the following companies mentioned in this article: Docker.
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.