Installing K3s on Debian Buster with Multipass

In this quick entry I’m just going to play with Multipass and K3s on my Debian box because I read a couple of articles about multipass and I want to give it a try.

First of all what is Multipass? According to this page it is a tool to launch and manage VMs on Windows, Mac and Linux that simulates a cloud environment with support for cloud-init. Get Ubuntu on-demand with clean integration to your IDE and version control on your native platform.

And what is K3s: certified Kubernetes distribution built for IoT & Edge computing.

Installing multipass

# apt install snapd
$ snap version
snap    2.42.5
snapd   2.42.5
series  16
debian  -
kernel  5.4.0-3-amd64
# mkdir -p /snap/bin
# export PATH=$PATH:/snap/bin
# snap install multipass --classic
multipass 1.0.2 from Canonical✓ installed

# snap list
Name       Version   Rev   Tracking  Publisher   Notes
core18     20200124  1668  stable    canonical✓  base
multipass  1.0.2     1597  stable    canonical✓  classic
snapd      2.42.5    5754  stable    canonical✓  snapd

# multipass launch --name foo
Launched: foo
# multipass list
Name                    State             IPv4             Image
foo                     Running           10.83.169.147    Ubuntu 18.04 LTS
# multipass exec foo -- uname -a
Linux foo 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

# multipass version
multipass  1.0.2
multipassd 1.0.2

# multipass stop foo
# multipass remove foo

# multipass shell
Launched: primary                                                               
Mounted '/root' into 'primary:Home'                                             
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-76-generic x86_64)
...
ubuntu@primary:~$
# multipass list
Name                    State             IPv4             Image
primary                 Running           10.83.169.197    Ubuntu 18.04 LTS
foo                     Deleted           --               Not Available

Copying your ~/.ssh/id_rsa.pub to the end of root/.ssh/authorized_keys you could access through SSH using IP 10.83.169.197

# ssh-keygen -t rsa
# cat ~/.ssh/id_rsa.pub
ssh-rsa 
...
root@fisher3
# multipass shell
ubuntu@primary:~$ echo "ssh-rsa 
...
root@fisher3" >> .ssh/authorized_keys

# ssh ubuntu@10.83.169.197
ubuntu@primary:~$ 

Installing K3s

root@primary:~# curl -sfL https://get.k3s.io | sh -

root@primary:~# kubectl get nodes
NAME      STATUS   ROLES    AGE    VERSION
primary   Ready    master   110s   v1.17.2+k3s1

# kubectl get pods --all-namespaces
NAMESPACE     NAME                                      READY   STATUS      RESTARTS   AGE
kube-system   local-path-provisioner-58fb86bdfd-lfnp9   1/1     Running     0          4m
kube-system   metrics-server-6d684c7b5-zp82z            1/1     Running     0          4m
kube-system   helm-install-traefik-zqpm5                0/1     Completed   1          4m1s
kube-system   svclb-traefik-t578j                       2/2     Running     0          3m21s
kube-system   coredns-d798c9dd-flt78                    1/1     Running     0          4m
kube-system   traefik-6787cddb4b-r7qfh                  1/1     Running     0          3m22s

Let’s add a node to our K3s cluster, but first we should recover our foo instance:

# multipass recover foo
# multipass start foo
# multipass exec foo -- bash
ubuntu@foo:~$ $ echo "ssh-rsa ... root@fisher3" >> .ssh/authorized_keys

root@primary:~# cat /var/lib/rancher/k3s/server/node-token
K102f847900ed92babf01bdabce7f57da40bc0eae6574e7152015cbf5d68288115d::server:3c33f458047cacf402ae3fc4a5f6d521

root@foo:~# curl -sfL https://get.k3s.io | K3S_URL=https://10.83.169.197:6443 K3S_TOKEN=K102f847900ed92babf01bdabce7f57da40bc0eae6574e7152015cbf5d68288115d::server:3c33f458047cacf402ae3fc4a5f6d521 sh -

root@primary:~# kubectl get nodes
NAME      STATUS   ROLES    AGE   VERSION
primary   Ready    master   54m   v1.17.2+k3s1
foo       Ready    <none>   13m   v1.17.2+k3s1

root@foo:~# mkdir ~/.kube
root@primary:~# scp /etc/rancher/k3s/k3s.yaml 10.83.169.147:~/.kube/config

root@foo:~/.kube# sed -i.bak -e 's/127.0.0.1/10.83.169.197/g' config
root@foo:~/.kube# grep server config
    server: https://10.83.169.197:6443
root@foo:~# chmod 644 ~/.kube/config
root@foo:~/.kube# kubectl get pods --all-namespaces --insecure-skip-tls-verify
NAMESPACE     NAME                                      READY   STATUS      RESTARTS   AGE
kube-system   local-path-provisioner-58fb86bdfd-lfnp9   1/1     Running     0          61m
kube-system   metrics-server-6d684c7b5-zp82z            1/1     Running     0          61m
kube-system   helm-install-traefik-zqpm5                0/1     Completed   1          61m
kube-system   svclb-traefik-t578j                       2/2     Running     0          61m
kube-system   coredns-d798c9dd-flt78                    1/1     Running     0          61m
kube-system   traefik-6787cddb4b-r7qfh                  1/1     Running     0          61m
kube-system   svclb-traefik-ccn9g                       2/2     Running     0          20m

As you can see this is a quick way to have a K3s cluster up and running.

Removing snapd

# apt remove snapd && apt purge snapd

Reference links:

That’s all folks!!

4 thoughts on “Installing K3s on Debian Buster with Multipass

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s