I want to write a book on teaching technology. I spent a lot of my time these days on thinking about this, and practicing at customer sites. I also enjoy gaming, and especially Hearthstone. A game that I both play and watch. Anette and I watch a lot of Day play Hearthstone, he is a fun guy, also with a passion for teaching and fun side-projects. So he announced that he would start a 30 day challenge in his community, The DayKnights. I set out to get started on my book, but I ran into a problem. I am a pathological yak-shaver! This blogpost will be concluded with a little guide for the setup that I built, while procrastinating on the writing.
In the world of lean agile software development or DevOps, we have many funny phrases. One I learned recently is Yak Shaving. Yak shaving is defined as an activity that while seemingly useless actually helps you in accomplishing your current goal.
I subscribe to the Seth Godin view from above. Yak Shaving is procrastination. It is postponing the real task because you don’t really grasp the totality, or don’t know where to start.
Getting this blog online is a very good example of me doing a ton of Yak Shaving, because writing is hard! I have a perfectly fine server hosted by Contabo. It is very much capable of hosting a WordPress site, and in fact is doing so excellently for multiple sites at the moment. But where is the fun in that. As a everything as code kind of guy, I started setting up a site using Jekyll , the static site and blog engine that we also use at Praqma. Of course it ended up working, but after a few evenings of tinkering I was still not satisfied. And where should I run this site?
So I decided to set up a Kubernetes cluster. To “Have a place to run my things…”
Turns out I do not really have things to run, but that is an aside.
I’m aware that there are different awesome ways to get a managed Kubernetes cluster, such a AWS, GKE, Digital Ocean or even Azure these days. But since I was not actually trying to solve a problem I decided that I should set up my own cluster. I have a fondness for Hetzner, cheap machines that seem to work well for everything that I’ve used them for yet. So I had a few different options. First I tried to figure out how to configure it manually, but as I did not understand a bunch of the elements I gave up there. So then I tried using kubespray. I think it worked, but I also had to do a lot of configuration first and that seemed to break.
So next up I found hetzner-kube which seemed like the perfect tool for me, set up a Kubernetes cluster using the new Hetzner Cloud. I even found this blogpost describing how to get the to point I wanted to be. After following this tutorial four times I kept locking myself out of my cluster, never being able to figure out why I never could deploy anything.
I moved to kube-adm set up the cluster a few times, but the network layer seemed to be botched each and every time. I still do not know why, but I am aware that it seems to be important whether you use flannel, calico or weave, and you can’t interchange them. Configuration is very different.
After all this I went back to Hetzner Kube, hoping that I had learned something along the way.
I failed yet another time with the tutorial mentioned above, but I tried again, and this time I deployed Traefik as ingress controller rather than nginx.
And behold. I had my Kubernetes cluster deployed with hetzner kube. I pulled it down, and up and down again. I finally settled on a three node, one master cluster, because if you can run useless stuff efficiently, why even bother!
This video from Malcolm in the Middle probably is the one that encapsulates my journey best!
So now we’re in a place where I can run my stuff in my Kubernetes cluster on the Hetzner cloud. I’m good to go. There’s even an example I could follow on how to do this. But that is obviously not the right way to set up a WordPress installation!
I obviously need Helm, the Kubernetes package manager.
Having cloned the repository I tinkered a bit with setting up the values file such that I could install a WordPress site.
Alas, people tend to assume that everything runs in the cloud. I figured out that I could use some annotations to set up Traefik as a ingress-controller, and helm just made that happen.
My pods where still not coming up as expected. Turns out the template for WordPress does not support non-cloud provider Persistent Volumes – and I was running with OpenEBS. I’ll be making a pull request to the WordPress ( and Mariadb ) Helm charts to add annotations to the persistent volume claim templates.
After all these procrastinations and side-tracks I finally have my WordPress blog running in Kubernetes. I surely learnt some stuff along the way and feel at lot more comfortable with kubectl. This has been a great exercise after reading Kubernetes up and running, seeing a bunch of videos and even following an edx course. Nothing beats actually working with it.
But wait, what was the purpose of me getting a WordPress site running? oh yes, back in the beginning I mentioned something about a 30 day DayKnight project. I wanted to write a blogpost on my very tiny endeavour into writing something for the DayKnight 30 day project.
The writers block
As discussed previously my challenge is not that I can produce text, but rather that I start Yak Shaving rather than writing. So I knew that I would like to write a book, but what toolchain do I need to write a book?
I knew from the beginning that I would write the blogpost using MarkDown. MarkDown is a plain-text format that has the advantage that it is pleasant to read in even the most rudimentary editors, but still impose some structure and formatting that makes it great for converting into different formats such as PDF, mobi or epub. For conversion to these ( and many, oh so many more ) formats I wanted to go with pandoc. A tool that attempts to be able to convert to and from all conceivable formats.
First my writing needs to live somewhere. I like Git, and it works very nicely together with MarkDown. Apparently you get a bunch of free stuff at GitLab, including 2000 minutes of free automation time each month.
I wanted to have some help in making my book the best possible, so I decided that I would at least to proselint, an python module that will test a set of rules against your writing. So far it has at least made me remove a ton of very’s.
For this purpose I’ve made a few helper files. I need a
requirements.txt in order to be able to install my prerequisites in a sane way. I’ve also made a simple shell script
goal.sh to measure progress. And finally I’ve written the actual pipeline
I’ve ended up with this pipeline that you can use in your own GitLab repository.
lint: script: - apt-get update -qy - apt-get install -y python-dev python-pip - pip install -r requirements.txt - proselint book/ - ./goal.sh
This pipeline will on all commits do linting and measure progress. Next steps would be to automatically build the ebook to PDF or similar.
All in all my DayKnight 30 day project was a success because I've taken more steps towards writing the book that I wanted (including actually writing a chapter), but not in the way that I expected.
Have fun and learn!