Cheap and local Kubernetes playground with K3s & Helm

Marco Villarreal
4 min readApr 7, 2019

--

If you are addressing to work with microservices you’ve better start getting familiar with kubernetes, this uber powerful container orchestation technology that everyone is excited about.

To use a kubernetes cluster you either have to install minikube(a virtual machine running a single kubernetes node) or expend a couple of dollars on some cloud managed kubernetes like GKE or AKS.

Either option can be a little expensive for some labs & playgrounds, while minikube keeps things local it is a little of a pain (virtual machines dude..), but this is not something I’ve figured out, it is something that people smarter than me already figured out so they created k3s.

Rancherlabs describe k3s as:

Lightweight Kubernetes, easy to install. A binary of less than 40 MB. Only 512 MB of RAM required to run.

And they don’t lie with such a big premise.

Installing

Really...? well let's do it, we are going to follow the recommmended steps for installing k3s in our local.

Validating the cluster

Once installed we already have a running k3s agent, to check it we just write some:

Here we can see our single node

Creating a storage class for your cluster

To make our local cluster even more functional we need to add a storage, so we will be using rancher's local-path-provisioner a local path storage for your k3s cluster.

Simple storage class configuration & validation

Installing helm

Helm is a package manager for kubernetes, basically is a powerful tooling for abstracting deployments into charts this makes easy to manage complex deployments; wich usually consist of multiple kubernetes objects(secrets, ingress, services, pods etc..) into versionable units of work.

Link Helm with tiller

Play a little with helm

Let's use some basic helm commands

Look for helm charts

For our test we are going to deploy a MySQL database, let's search for a mysql chart. To search we will use the command helm list followed by what we are searching(in this case mysql).

helm search mysql

We can see all posible options for mysql on helm repos

Make some test deployment on Helm

Once we choosed our chart stable/mysql we are going to customize it with some basic values like: persistence and default users.

This file is a basic example of wich customization we can make to our charts

Once created our values file we proceed to install it

Once writed this command you will se the output below
The output shows what helm did on the background(created a deployment, a service, a secret, persistent volume)

Check the installation with:

helm list

We can identify our deployment with the label we specified when running helm install

Check the connection

To check the MySQL connection we are going to use port-forwarding to enable a connection from our machine to the service

You have to open a second terminal to check your connection or end you port-forward command with &
This is a successful message of the port-forward
That’s it, with some simple steps we created a mysql deployment on kubernetes using helm

--

--