s0x IT Services Cloud How to deploy a Kubernetes cluster with Multipass

How to deploy a Kubernetes cluster with Multipass

How to deploy a Kubernetes cluster with Multipass post thumbnail image

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

istock-518142550.jpg

Ralwel, Getty Images/iStockphoto

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 https://get.k3s.io | 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

<a href="http://s0x.org/wp-content/uploads/2020/03/how-to-deploy-a-kubernetes-cluster-with-multipass-1.jpg" target="_blank" data-component="modalEnlargeImage" data-headline="

The K3s Kubernetes instance is running on the master.

” data-credit rel=”noopener noreferrer nofollow”>multipassclustere.jpgmultipassclustere.jpg

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

<a href="http://s0x.org/wp-content/uploads/2020/03/how-to-deploy-a-kubernetes-cluster-with-multipass-2.jpg" target="_blank" data-component="modalEnlargeImage" data-headline="

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

” data-credit rel=”noopener noreferrer nofollow”>multipassclustere.jpgmultipassclustere.jpg

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

<a href="http://s0x.org/wp-content/uploads/2020/03/how-to-deploy-a-kubernetes-cluster-with-multipass-3.jpg" target="_blank" data-component="modalEnlargeImage" data-headline="

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

” data-credit rel=”noopener noreferrer nofollow”>multipassclusterh.jpgmultipassclusterh.jpg

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:

K3S_TOKEN=ID

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 https://get.k3s.io | 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 https://get.k3s.io | 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

<a href="http://s0x.org/wp-content/uploads/2020/03/how-to-deploy-a-kubernetes-cluster-with-multipass-4.jpg" target="_blank" data-component="modalEnlargeImage" data-headline="

Our Kubernetes cluster is up and running.

” data-credit rel=”noopener noreferrer nofollow”>multipassclusterm.jpgmultipassclusterm.jpg

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

Related Post

Hundreds of thousands of Android users hit by Google Play spywareHundreds of thousands of Android users hit by Google Play spyware

<div class="teaser-image"> <a href="/it-infrastructure/security/8569/hundreds-of-thousands-of-android-users-hit-by-google-play-spyware"><img src="http://s0x.org/wp-content/uploads/2020/05/hundreds-of-thousands-of-android-users-hit-by-google-play-spyware-1.jpg" /></a> </div> <span class="field field-name-field-article-type field-type-taxonomy-term-reference field-label-hidden"> <span class="field-item even"><a href="/news">News</a></span> </span><div class="field field-name-field-published-date field-type-datetime field-label-hidden"> <div class="field-items"> <div class="field-item even"><span class="date-display-single">15 May, 2020</span></div> </div></div><span

Industry 4.0 | Cloud technology within ManufacturingIndustry 4.0 | Cloud technology within Manufacturing

<img width="640" height="426" src="http://s0x.org/wp-content/uploads/2019/10/industry-4-0-cloud-technology-within-manufacturing-1.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="Industry 4.0 | Cloud technology within Manufacturing" style="float: right; margin-left: 5px;" link_thumbnail="" srcset="http://s0x.org/wp-content/uploads/2019/10/industry-4-0-cloud-technology-within-manufacturing-1.jpg 1024w, http://s0x.org/wp-content/uploads/2019/10/industry-4-0-cloud-technology-within-manufacturing-2.jpg 300w, http://s0x.org/wp-content/uploads/2019/10/industry-4-0-cloud-technology-within-manufacturing-3.jpg 768w, http://s0x.org/wp-content/uploads/2019/10/industry-4-0-cloud-technology-within-manufacturing-4.jpg 640w, http://s0x.org/wp-content/uploads/2019/10/industry-4-0-cloud-technology-within-manufacturing-5.jpg 610w, http://s0x.org/wp-content/uploads/2019/10/industry-4-0-cloud-technology-within-manufacturing.jpg