Using Kubernetes to manage and coordinate multi-container or distributed applications is becoming more and more common and necessary as certain software architectures become standardized as “best practices.” This makes learning how to use Kubernetes (or K8s) an important skill for all web developers to at least gain a basic working knowledge for troubleshooting purposes.
Whether you are just working through your first tutorials, or you’re a seasoned senior K8s administrator, there is one chore that never goes away when dealing with your k8 setup — filling out the configuration YAML files. I suppose you could, theoretically, manually create each object, imperatively, from the command line to avoid the horrors of yaml writing, but this becomes impossible as your application scales up and you need to rely on the control plane automation for the app to even run with more than a handful of users.
No matter how many times you write out a basic boilerplate deployment config, it is impossible to remember exactly what needs to be there the next time you make one. It’s not like they are these crazy incomprehensible documents either, they make perfect sense when reading them — they just literally describe the desired working state of the deployment/service/whatever you need, and k8s does the rest of the work for you. There is some sort of psychological sorcery involved in these yaml files, however, that make the specifics flow out of your mind like a sieve.
So far the main technique I have used to write out all my configs has been Googling the specific object I’m trying to create and copying off of the default config docs, adding the necessary info for my use case. The official Deployment and Service docs have seen heavy use, as well as the other various controllers and services I might need to use. After writing out the first deployment, service, and ingress based off Google or checking some older app of mine, I usually just duplicate them as needed within my infra directory and change the names and details.
A New Solution
The folks over at Octopus Deploy have created a really handy reference page that might save you a lot of time when setting up your yaml configs: The Kubernetes Yaml Generator! Through convenient and easy to read dropdown menus, you can go through all the options for a k8s config. Every option has a convenient description to go along with it, as well as a link to the relevant documentation for more info. It generates the complete yaml as you change the settings, making it a live, up-to-date, interactive way for you to create all of your config files.
Maybe this tool can provide much needed relief from the endless yaml googling we all fall into during our k8s endeavors!