Image from https://unsplash.com/photos/MOO6k3RaiwE

From zero to Zerotier in k3s way

Juan Pablo Caivano
IoTOps
Published in
3 min readApr 27, 2020

--

The aim of this guide, is to provide you with an easy way to deploy your own zerotier controller in a raspberry pi, using k3s. Before thinking on hosting a zerotier controller, consider to use the one that zerotier provide at my.zerotier.com (you can have up to 100 devices connected in the same network without spending a penny). In that way you just simple need to create a network at their web page, join and authorize the devices, and that is, no further reading needed.

But what happens when you have a raspberry gathering dust, feeling that you have resources and time to play with k3s, and wanting to be in control of everything? You could create your own zerotier’s controller, and have unlimited devices connected. Before taking this approach, you should consider take a look at Zerotier’s license terms, spoiler alert, in most cases Free license applies, so no needs to worry about it.

So, I will give you some quicks steps to go from zero to zerotier controller in kubernetes, without pain (?), based on the work of key-networks controller.

Install k3s

I don’t want to go very deep on this, you can check the documentation at rancher’s site.

To keep it simple, you could do:

curl -sfL https://get.k3s.io | sh -

Deploy a manifest into it

After that, you could deploy a manifest containing the helm chart for zerotier controller we had built. Put the following content into a file named ztncui.yaml

apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: zerotier-controller-ui
namespace: kube-system
spec:
chart: https://iotops.gitlab.io/charts/ztncui-0.1.0.tgz
targetNamespace: default
set:
ingress.hosts[0]: zt.labs.3xmgroup.com

And then, deploy into k3s:

sudo k3s kubectl apply -f ztncui.yaml

Wait for the deployment to be completed

$ kubectl get pods --all-namespaces --watch
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system metrics-server-6d684c7b5-n75qz 1/1 Running 0 3m55s
kube-system local-path-provisioner-58fb86bdfd-8v7jf 1/1 Running 0 3m55s
kube-system helm-install-traefik-5vjlz 0/1 Completed 0 3m55s
kube-system coredns-6c6bb68b64-844nl 1/1 Running 0 3m55s
kube-system svclb-traefik-25t24 2/2 Running 0 3m24s
kube-system traefik-7b8b884c8-djntt 1/1 Running 0 3m24s
kube-system helm-install-zerotier-controller-ui-lnz4p 0/1 Completed 0 12s
default zerotier-controller-ui-ztncui-cd97c5744-fph9l 0/1 Init:0/1 0 10s
default zerotier-controller-ui-ztncui-cd97c5744-fph9l 0/1 PodInitializing 0 34s
default zerotier-controller-ui-ztncui-cd97c5744-fph9l 0/1 Running 0 37s
default zerotier-controller-ui-ztncui-cd97c5744-fph9l 1/1 Running 0 39s

Access to the Controller UI

When the pods goes into the Running state, you should be able to port-forward the service, and access to a UI where you will create a network, setup the IP, and authorize new members to join in.

kubectl port-forward svc/zerotier-controller-ui-ztncui 3000:3000

To access, point the browser to http://127.0.0.1:3000, the default username and password is admin/password.

Let me know if you face any problem with this approach, I’ll be happy to help you.

--

--

Juan Pablo Caivano
IoTOps
Editor for

DevOps Architect at 3XM Group, aka Pulpo. Geek, GNU/Linux’s fan. OpenSource solutions makes me happy.