Zero To Kubernetes
Tags: kubernetes, automation, devops, showdev
Published: 2020-05-26 13:16:00

---
title: Zero To Kubernetes
published: true
description: How to quickly set up a local Kubernetes Environment with one line
tags: Kubernetes,Automation,DevOps,showdev
---

### Elevator-Pitch
Who doesn't love kubernetes? 
Who also doesn't love, if things just work without much tinkering, **automagically**?
If you do like both of these things, this might be a post for you!

While I like using k8s, I dislike the part about cleaning stuff up after long sessions of deploying dozens of containers.
Only to recreate the cluster again later. And damn it, I forgot to deploy grafana again... 

So I automated the setup/teardown of this, using a few handy tools and some Bash Scripting to incorporate more laziness in my workflow. 

### Grand Reveal 
I call it [zero-to-k8s](https://github.com/RHabereder/zero-to-k8s), or if you want a niftier name: **02k8s**
Which is totally readable and everyone instantly understands what it means. Right? **Right?!**
I better leave the title as it is, I think. 

### So, what is it?
Essentially it is a glorified bash-script that downloads the typical binaries you need, for example kubectl, helm, k3d and the likes. 
Everything you need to use kubernetes and a little more for comfort. 

It then calls all those binaries, creates a k8s cluster and also deploys some workloads of tools you decided are worthy. 
Deployment, Service, Ingress and all the other nice things you need for them. 
Just one kubectl port-forward away from displaying in your favorite browser (as long as they are not w3m or lynx)

### Where the laziness comes into play
There are two versions of the script, one having to be edited every time you want something to change.
And second, my favorite version (the lazy one) that pops up some dialogs and asks you annoying questions, so you don't have to do annoying editing every time. 
Unfortunately we have to die one annoying death, since my mind-reading interface is not done yet. 

### Awesome Demo
Why don't I just give you the grand tour of how it works?
Behold the blue curses widget goodness:

![Demo GIF](https://dev-to-uploads.s3.amazonaws.com/i/x1qgrbca28xz57iw8mmp.gif)


### The things I used:
k3s - A stripped down kubernetes runtime developed by rancher, or as they call it "a highly available, certified Kubernetes distribution designed for production workloads in unattended, resource-constrained, remote locations or inside IoT appliances" 
k3d - Another tool made by rancher to deploy k3s inside docker. 


### The things you need:
```
WSL/Bash/MacOS ZSH (bless you if you get to work on a real Linux)
Docker (the whole "k3s in docker" approach probably won't work without it) 
Dialog (if you want to be as lazy as possible)
Access to the internetz (Or a very patient IT-Sec Department that downloads stuff for you)
```

### I don't like it, make it go away!
To kill your cluster and thanos-snap it away (50% of the time it works all the time, or so I've been told), all you need is one line:

```
./bin/k3d delete --name dev
```
No harm, no foul, you do you my friend. I promise I won't take it personally!
As every good technician, the entire blame is on the tools, obviously.

### What do I want to do with this thing?
To be honest, all I want is to continue to automate as much as possible, to enjoy a coffee during all the boring tasks that just take unnecessary amounts of time. 
And learn of new tools and probably automate them away too. 
So if you got something that just has to go in there, don't shy away from shooting me a message.

I hope some of you find this as helpful as I do, let's go and automate the rest of the world!