Using K3s and Helm for Local Kubernetes Fun

The industry is moving towards containers and Kubernetes (K8s) won the rat race to become the standard platform. However, K8s is a daunting platform to run. Many projects try to make it easier in the cloud like Rancher and Amazon’s EKS. Running it locally is even harder, but Minikube made it possible with virtual machines. Now we have a new player coming out of Rancher Labs called K3s.

“Easy to install. A binary of less than 40 MB. Only 512 MB of RAM required to run."

Perfect for Raspberry Pis and local development purposes.

How does it take a big complex platform like Kubernetes and bundle it down to a 40MB binary on 512MB of RAM?

  • Removes Legacy, alpha, non-default features.
  • Removes in-tree plugins (cloud providers and storage plugins) that can be added in
  • Replaces etcd3 with Sqlite3
  • Adds TLS management
  • Comes Wrapped in a simple launcher
How K3s works

Excited yet? Let’s get started.

Since it’s written in Go, it’s all contained in a single binary. You can download it from the releases page or use your package manager.

$ k3s server

If you run into errors with containerd, try using docker (not recommended):

$ k3s server --docker

You should be able to get some basic information now

$ export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

$ kubectl cluster-info
Kubernetes master is running at https://localhost:6443
CoreDNS is running at https://localhost:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

That’s it. You are now running Kubernetes on your machine.

Let’s start playing with it.

Helm Basics

Helm is the standard for deploying applications on K8s. Think of it as the package manager for Kubernetes.

Helm packages are called “charts” and deployments are called “releases”.

They can define much more than just simple putting your application on K8s. Helm defines your deployment as code by specifying things like replication count, anti-affinity, lifecycle hooks, and dependent charts. Templates can be customized for different environments like production, pilot, and local development. Which makes it more powerful than running something like kubectl run myapp --image=localhost:5000/myapp.

# Installs tiller on K8s, should already be installed though
$ helm init

# Updates Repo
$ helm repo update

There’s some useful charts you can install to help with local development:

$ helm install stable/redis
$ helm install stable/postgresql
$ helm install stable/nats

You can run some home automation applications on K3s using Helm. Which makes running a little raspberry pi K3s cluster a cool weekend project.

Use helm search and Helm Hub to find more!

K3s brings Kubernetes to people who may not be able get their hands on powerful servers or can pay for the cloud. They can run their desktop off a raspberry pi and K3s on another.