If you are like me, you are continually frustrated by out of date documentation. One day, someone will start a company specializing in deleting out of date documentation. At the time of writing the newest Kubernetes is 1.8, but I’m sure in about 15 minutes 1.9 will come and blow us all away with is magical complexity like the ending of the movie Interstellar.
Lets get started, we will do this in interview format. I will play the role of the Human and YgBot will play the role of the instructor.
Human: “So how do I run stuff like MongoDb on Kubernetes?”
YgBot:” Search results indicate that You can use a StatefulSet. It is basically a static replica set paired with a headless service. A headless service does not expose a cluster ip, but instead you are expected to reach out to the individual pods within the set. I found a resource here, http://blog.kubernetes.io/2017/01/running-mongodb-on-kubernetes-with-statefulsets.html”
Human: “Cool, so…. can haz the YAML ? Also I need it to work with AWS, so surprise me.”
YgBot: “Static Code analysis routine has produced the following output with no guarantees. Ygrene nor any of its employees are providing any warranty on this software. Here is the code:”
Human: “Sweet lets try it…. paste paste paste.” (10 minutes later) “It didn’t work what the crap?”
YgBot: “Quantum Emotion analysis indicates that you didn’t read any of the Yaml and that you Kubernetes cluster is not setup correctly to use this. Recommended course of action is to activate the “Step By Step” example program.”
YgBot: “Lets start with the assumptions this file is making:
- You are on AWS and Kops setup your cluster.
- You used the EFS provisioner to allow you to (like a straight up G) use EFS for volumes instead of silly EBS which has “limits”. See https://github.com/kubernetes-incubator/external-storage/tree/master/aws/efs
These assumptions only change one part of the file, the Volume Claim Template. If you wanted to do it on a different volume backed or on a different cloud you can make that simple change right there in lines 52–55"
Human: “Cool, lets keep going.”
YgBot: “I’m sorry, did you say ‘I need to pickup sewing?’ finding results on learning to sew….”
Human: “No! NEXT STEP!”
YgBot: “Right, lets break down the spec template for the stateful set.”
`updateStrategy: type: RollingUpdate`
“This specifies that updates will create pods and replace them one at a time. Note there are restrictions to what you can edit after a StatefulSet is created.”
`replSet” — rs0 — “ — smallfiles” — “ — noprealloc”`
“These are arguments to the Mongo Entrypoint docker to say I want a replica set from mongo.”
“Next comes the magic that makes it all work.”
“You will notice that we are deploying another Docker container with every Mongo instance. It is a Node.js app that handles configuring the Mongo replica set and maintaining leadership throughout the life of the mongo cluster. The original wasn’t working so I forked it and updated the Kubernetes node client to ensure the apis are in compliance with 1.8.”
Human: “Holy Crap it works! YgBot, play ‘We are the champion’ by Queen from Spotify”