How to deploy a Kubernetes cluster with Multipass

Looking for the easiest way to deploy a Kubernetes cluster? Get it done in under five minutes with Multipass.

How to deploy a Kubernetes cluster with Multipass

Multipass is a new-ish tool that makes deploying virtual machines (VMs) for development about as easy as it gets. With Multipass you can spin up a fresh Ubuntu environment with a single command from Linux, Windows, or macOS. 

For those that are looking to develop on a Kubernetes cluster, you're in luck. With the help of k3s, you can deploy a Kubernetes cluster with ease. 

I'm going to show you how to do just that.

SEE: Flash storage: A guide for IT pros (TechRepublic Premium)

What you'll need

In order to make this work, you'll need Multipass installed on your platform of choice. I'll be demonstrating on Pop!_OS, but what operating system you use shouldn't matter.

On the off-chance you haven't installed Multipass, you can do that on any distribution of Linux that supports snap with the command:

sudo snap install multipass --classic --stable

Once you have Multipass up and running, you're ready to go.

How to launch your virtual machines

The first thing we'll do is launch three virtual machines to serve as the Kubernetes master and nodes. We're going to configure these VMs for:

  • Name

  • Number of CPUs

  • Total Memory

  • Total storage

First launch the master with the command:

multipass launch --name k3s-master --cpus 1 --mem 1024M --disk 3G

Next, launch the two nodes with the commands:

multipass launch --name k3s-node1 --cpus 1 --mem 1024M --disk 3G
multipass launch --name k3s-node2 --cpus 1 --mem 1024M --disk 3G

Once those are up and running, you're ready to continue.

How to deploy the Kubernetes master

With a single command you'll download an installation script into the running master VM, set a permission, and run the script. That command is:

multipass exec k3s-master -- /bin/bash -c "curl -sfL | K3S_KUBECONFIG_MODE="644" sh -"

The above command should complete in about thirty seconds. When it finishes, you should see "Starting k3s" (Figure A).

Figure A


The K3s Kubernetes instance is running on the master.

Before you deploy the nodes, you need to first find out the IP address of the master. To do this, issue the command:

multipass list

You should see the IP address of your master listed (Figure B).

Figure B


The IP address of our Kubernetes k3s master is listed under IPv4.

Next, we need the Kubernetes join token from the master. To do this, you have to gain access to the VM shell with the command:

multipass shell k3s-master

Once inside the shell, locate the join token with the command:

sudo cat /var/lib/rancher/k3s/server/node-token

Copy and paste the token presented to you (Figure C).

Figure C


Our Kubernetes join token is ready to be pasted into the join command.

How to deploy and join the Kubernetes nodes

Before we issue the command to join the first node to the cluster, pass the join token value to a shell variable like so:


Where ID is your join token.

Once your token is saved as the K3S_TOKEN variable value, join the first node with the command:

multipass exec k3s-node1 -- /bin/bash -c "curl -sfL | K3S_TOKEN=${K3S_TOKEN} K3S_URL=${K3S_NODEIP_MASTER} sh -"

Join the second node with the command:

multipass exec k3s-node2 -- /bin/bash -c "curl -sfL | K3S_TOKEN=${K3S_TOKEN} K3S_URL=${K3S_NODEIP_MASTER} sh -"

How to check your Kubernetes cluster

To make sure all is working, gain access to the k3s-master shell with the command:

multipass shell k3s-master

Once in the shell, issue the command:

kubectl get nodes

You should see both nodes and the master are ready to go (Figure D).

Figure D


Our Kubernetes cluster is up and running.

Congratulations, you just launched a full-blown Kubernetes cluster in less than five minutes. Jump in and start developing.

Also see


Ralwel, Getty Images/iStockphoto