This weekend's learning activity was figuring out a good way to make k8s templates out of my YAML files. There are a number of ways to do this, including from Ansible or Helm, but after looking at Kustomize, that's the best way for me to go.

Ansible could do it by either:
a) native k8s modules in ansible
b) with YAML files, and the template function, which would just do variable substitution

Helm is extremely overkill for my use case, although I'm sure I could get it to cooperate.

Kustomize is the best mix of $inputFiles + modifications = $outputFiles per environment, and I really like how it works.

You define your top level YAML files and then tell the environments in an overlays/ directory how you want things to change. You can even have it apply a namespace to all resources in there so it's never forgotten or replace values such as ingress hostnames, which have to be unique per env anyways.

This will let me write one set of files and then push the YAML to k8s properly. I also fully intend to use this for a DR kind of situation where I need to recover everything.

All of this will fit very well into my new Gitea instance, replete with an Actions runner.

#homelab #k8s #kubernetes #kustomize #learning #neverstoplearning #technology #yaml #selfhosted

I've mentioned before how I like to test out a tool to know if it works for me and this is another good example of that. I was able to get Kustomize working the way I wanted in a very short amount of time.

#homelab #tech #technology

@heatsink Wait until you discover what you can do with components ;)

It's amazing and terrible to standardise stuff.

Amazing, if you get all the defaults in the base right (e.g. you already have a labels object around). And terrible if you don't because you need to add it, which might replace existing stuff or when you want to define common labels and notice how things need to be structured.

https://git.shivering-isles.com/shivering-isles/infrastructure-gitops/-/tree/0bb3d05abed9b707f052c81e7417fd4ad35ff214/shared/components

This is what I use, and it works quite good. Have fun!

shared/components · 0bb3d05abed9b707f052c81e7417fd4ad35ff214 · Shivering-Isles / Infrastructure GitOps · GitLab

GitOps-based setup for infrastructure, including all tooling and instructions for bootstraping

GitLab

@sheogorath I’ll have to take a look at them later to learn more. I’m not sure if you have any specific examples you can link to in that repo?

My plan is to get all of my resource deployments into pipelines, one namespace at a time.

@heatsink there's lots of options with K8S. At work we use Helm Charts, orchestrated with Skaffold. Yes, it's more layers of abstraction, but with a helm chart you can roll-back if you need to, Skaffold gives you context around why (and where) you're deploying a helm chart to a server. Of course, this is just how we work, and how I find it useful to deploy - your use case will be different, but I'd be happy to give some examples if that would be useful :)
@heatsink have you tried KCL ? Didn't have a chance to try it myself, it's a CNCF sandboxed project.
https://www.kcl-lang.io/
KCL programming language. - Mutation Validation Abstraction Automation Production-Ready | KCL programming language.

KCL is an open-source constraint-based record & functional programming language mainly used in configuration and policy scenarios.

@sinux haven’t heard of KCL before this. If you have any examples of tempting a k8s YAML file with KCL, I would be interested!
@heatsink no exemples yet, I'll post when I have time to try :-)