Intro: k3s, a less needy Kubernetes,
Tags: kubernetes, iot, edge
Published: 2019-08-01 13:08:39

---
title: Intro: k3s, a less needy Kubernetes,
published: true
description: Intro: k3s, a less needy Kubernetes.
tags: kubernetes, iot, edge
cover_image: https://blog.davidjeddy.com/wp-content/uploads/2019/08/k3s-feature-1.png
---

<!-- wp:heading -->
<h2>What is all this?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The <a href="https://k3s.io/">official documentation</a> states "...<code>k3s</code> is a intended to be a fully compliant production-grade Kubernetes distribution with [the following] changes...". But what does that <code>mean</code> in layman's terms? It means Kubernetes has a lot of functionality that is not 100% required  in the use case of IoT, Edge computing, or lower powered hardware. For example the <code>kubeadm</code> has some high hardware requirements. and runs very slowly on lower power / high latency hardware. Taking this further running <code>k8s</code> worker nodes on an ARM chip is a practice in frustration. Enter <code>k3s</code>, lower hardware is no longer a hard barrier for entry.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Up and Running</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Installation is very straight forward. I would say <em>almost</em> as easy as <code>apt-get install</code>. Since <code>k3s</code> is aimed at Edge and IoT Debian is rarely the chosen OS. So instead it uses <code>curl</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>curl -sfL https://get.k3s.io | sh -</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Execute the above in a terminal, the output should look similar to the following.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>&#91;INFO]  Finding latest release
&#91;INFO]  Using v0.7.0 as release
&#91;INFO]  Downloading hash https://github.com/rancher/k3s/releases/download/v0.7.0/sha256sum-amd64.txt
&#91;INFO]  Downloading binary https://github.com/rancher/k3s/releases/download/v0.7.0/k3s
&#91;INFO]  Verifying binary download
&#91;INFO]  Installing k3s to /usr/local/bin/k3s
&#91;INFO]  Skipping /usr/local/bin/kubectl symlink to k3s, command exists in PATH at /usr/bin/kubectl
&#91;INFO]  Creating /usr/local/bin/crictl symlink to k3s
&#91;INFO]  Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
&#91;INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
&#91;INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
&#91;INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
&#91;INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
&#91;INFO]  systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
&#91;INFO]  systemd: Starting k3s
</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Running <code>ps aux | grep k3s</code> returns our query with confirmation that k3s is indeed running.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1776,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://blog.davidjeddy.com/wp-content/uploads/2019/08/joey-kyber-45FJgZMXCK8-unsplash.jpg" alt="" class="wp-image-1776"/><figcaption>Photo by <a href="https://unsplash.com/@jtkyber1?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Joey Kyber</a> on <a href="https://unsplash.com/search/photos/speed-light?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Subsequent start ups of the master node is accomplished via an event shorter command.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>echo 'Run the k3s server...'
sudo k3s server &amp;
# Kubeconfig is written to /etc/rancher/k3s/k3s.yaml
sudo k3s kubectl get node</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>If the Rancher team was going for <code>shortest commands possible</code>, they win.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Now on to worker nodes. To join a worker node to a cluster it is also nearly as easy.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>echo 'Run a k3s worker node...'
# On a worker node, run the following.
# NODE_TOKEN is on the server @ /var/lib/rancher/k3s/server/node-token
sudo k3s agent --server https://master_node:6443 --token ${NODE_TOKEN}</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>That is it. Three different commands to get a master and worker nodes installed, running, and joined together. Who said Kubernetes was confusing. (I am joking., k8s can be very confusing.)</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Any Example Usage Case</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As I wrote this posting an colleague of mine reached out to me asking how I would put together a system that could monitor the status of and receive data from a wide range of in-situ IoT devices for agriculture. The system needs to be able to tell what devices are online, the health of the system as well as receive data streams from the system. Once the data ingested and analyzed alerts and reports would be generated. The in-situ devices would be as lower-powered and very isolated, likely run off solar with a local battery pack. During the <code>proof of concept</code> phase Raspberry Pi 3's with custom enclosures would be the deployed IoT devices. Bam! Perfect case for <code>k3s</code>. When the device starts the startup script would instruct the device to join the cluster via a master node running on a ARM server (probably a AWS EKS master really). Then machine and sensor data could be feed into Kinesis Firehose to analysis. Bam, done.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1777,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://blog.davidjeddy.com/wp-content/uploads/2019/08/zan-ilic-wGqz5YSqsfk-unsplash.jpg" alt="" class="wp-image-1777"/><figcaption>Photo by <a href="https://unsplash.com/@zanilic?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Zan Ilic</a> on <a href="https://unsplash.com/search/photos/iot?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Wrap Up</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>I can hear you saying 'so soon'? Well...yes. k3s really is that easy. One command to install, one command to start, one command to join. I would even dare to say it is easier to operate than Docker.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>What do you think. Does Kubernetes have a place with Edge and IoT devices; or is it overkill like technology engineers so often tend to do? Let me know in the comments below.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Additional Reading</h2>
<!-- /wp:heading -->

<!-- wp:list -->
<ul><li><a href="https://k3s.io/">https://k3s.io/</a></li><li><a href="https://github.com/rancher/k3s">https://github.com/rancher/k3s</a></li><li><a href="https://rancher.com/blog/2019/2019-02-26-introducing-k3s-the-lightweight-kubernetes-distribution-built-for-the-edge/">https://rancher.com/blog/2019/2019-02-26-introducing-k3s-the-lightweight-kubernetes-distribution-built-for-the-edge/</a></li><li><a href="https://rancher.com/tags/k3s/">https://rancher.com/tags/k3s/</a></li><li><a href="https://blog.alexellis.io/test-drive-k3s-on-raspberry-pi/">https://blog.alexellis.io/test-drive-k3s-on-raspberry-pi/</a></li></ul>
<!-- /wp:list -->