DEV Community

Raphael Habereder
Raphael Habereder

Posted on • Updated on

Zero To Kubernetes


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, 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

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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!

Discussion (9)

eucariop profile image
Eucario Padró

I see interesting CI components. ArgoCD or Jenkins?

habereder profile image
Raphael Habereder Author • Edited on

For now I only have

  • tekton
  • concourse
  • rio (not functional as of yet)

Definitely on the list and probably in one of my PoC branches :D

I liked drone at first glance too, so I'll take a look at that one too.

Could be done too, though I am not quite sure how to provision everything for k8s deployments smoothly without the user having to do a lot of things by hand. It should be automated as much as possible and the Jenkins groovy API doesn't really help much in that regard :D

Is pretty much 90% tekton, so I think I'll leave that out for now, until they add something that you can't get with vanilla tekton.

You got ideas for other cool tools, or miss something? Feel free to ask :)

habereder profile image
Raphael Habereder Author • Edited on

Yep, ArgoCD was there, sleeping in a PoC Branch.
So I finished integrating it yesterday evening, if you want to have a go at it, feel free :D

Though I don't have a sample pipeline ready for it, that will follow as soon as I get the time to play with Argo a little.

eucariop profile image
Eucario Padró

Nice and short article there is this script you can try on Mac?

habereder profile image
Raphael Habereder Author

It might work on mac, I am not sure to be honest.
I don't have a Mac, so testing against it wasn't really doable.

I was already planning on getting a working hackingtosh some day, so I'll move that up the pipeline, maybe I can get it to work on Mac too :)

habereder profile image
Raphael Habereder Author • Edited on

Edit: @eucariop :
It is done, it now works on Mac too :)

Alright, I got my hands on a Macbook. If you are still interested, I'll implement Mac Support, or at least will try to :)

eucariop profile image
Eucario Padró

Congratulations, Raphael!

eucariop profile image
Eucario Padró

istio-ingress.yaml all components?

habereder profile image
Raphael Habereder Author

I've not had a lot of time for my project lately, but it is in the works and should be implemented and available sometime the next few days.