The Weird and Wonderful Way I Deploy Manifests to my Homelab
Anthony OleinikThere was originally a long article here about how I got to where I am, and I figured no one would read it so I added this TL;DR at the top.
Turns out, the TL;DR was much better than the article itself so I got rid of it and just kept the TL;DR.
tl;dr:
- I use cdk8s to create manifests. I have a nix derivation that generates the manifests.
- I create the images I need with nix-snapshotter, and then use
kustomize
to put the image with the correct tag into the manifests. Fully declarative manifests! - I use colmena to basically
nixos rebuild switch
across many nodes. - Those manifests get statically served in-cluster by rclone…
- which fluxcd scans every 30 seconds for new, dead, or updated manifests.
- flux applies my manifests!
The benefits of my rube-goldberg machine are:
- flux garbage collects old manifests. This means I don’t have to manually remove dead manifests from the API server.
- CDK8’s stops me from shooting myself in the foot by e.g. exposing the wrong port of a service.
- By serving through rsync instead of git pushing, I can iterate quickly buy not having to make a git commit for every change. We’ve all been there:
did it work commit1
,did it work commit2
, … Flux doesn’t have an http server source btw - only S3. - My manifests are tied to my nixos config, so I can change the hardware and the manifests in lockstep.
So far, it’s working great! I need some sort of notification that tells me if fluxcd is failing to reconcile… perhaps an arduino with a LED that turns red if it can’t reconcile/foreshadow!?
the entire apply cycle takes roughly a minute and a half. A minute to build the manifeststhis is my fault - a ton of things get rebuilt that don’t need to. At some point I need to go audit my nix file sets, and 30 seconds for flux to pick up the manifests and begin to reconcile.