1
0
Fork 0
mirror of https://git.sr.ht/~goorzhel/turboprop synced 2024-12-15 17:50:52 +00:00
Commit graph

80 commits

Author SHA1 Message Date
Antonio Gurgel
0f7f384137 Create mkChartsWithNixhelm; export appT 2023-12-03 23:03:36 -08:00
Antonio Gurgel
3a6246ab83 Final refactor
Make flake importable at top level.
Move app-template to `./src`, removing `charts` from `./lib`.
Clean up unused bits elsewhere.
2023-12-03 21:45:40 -08:00
Antonio Gurgel
6907ae7373 Clean up 2023-12-03 21:29:15 -08:00
Antonio Gurgel
af56c2be50 Truck in namespaces 2023-12-03 20:54:47 -08:00
Antonio Gurgel
ec3276b493 Truck in user data from own flake
Same rationale as 0790be8.
2023-12-03 20:03:13 -08:00
Antonio Gurgel
97dbdec7f7 Re-implement service-builder
`apiVersions` gave me a headache while writing the foldl so I made it
a separate input.

Now the service modules have this signature, without my having to
change any code in the modules themselves:

{charts, etc, ...} -> [apiVersion] -> {out, extra}
2023-12-03 19:58:28 -08:00
Antonio Gurgel
797ae401ae Truck in haumea 2023-12-03 17:07:21 -08:00
Antonio Gurgel
70fae512d1 Refactor crisis
Two imperfections have come to bite me simultaneously:
- I wanted strict ordering of services but implemented it very sloppily.
- The flake builders represent implementation leakage. I want to present
  a clean interface to users, not "first, you must evaluate these
  twenty-eight variables".

So now I'm fixing too many things at once. Luckily it's hard to lose
things in Git.
2023-11-29 23:06:13 -08:00
Antonio Gurgel
ce881f0c0d Keep writing 2023-11-28 22:08:54 -08:00
Antonio Gurgel
6faf8d9aa4 Provide derivation-builder 2023-11-27 00:35:19 -08:00
Antonio Gurgel
84b62768b4 Add flake-builder input for user data
I stowed my particularities in lib.eureka, but exporting
`packages.*.flakeBuilders` with a pre-pressed `lib` left no way to put
the Eureka module back in. After further consideration, I decided
it's wise to keep `lib`	that way instead of commingling it with
homelab data.
2023-11-27 00:13:06 -08:00
Antonio Gurgel
e3b6f47d1e Export built charts as well 2023-11-27 00:01:47 -08:00
Antonio Gurgel
bc64f70610 Remove everything specific to my cluster 2023-11-26 23:41:14 -08:00
Antonio Gurgel
ffc18857a5 Export lib.rake 2023-11-26 22:38:11 -08:00
Antonio Gurgel
c4bb826b2a Rename project to turboprop
Getting away from manually pressing Helm charts (while, importantly, retaining
integrity checking and determinism) is something I liken to the
transition from sail to flight as the primary mode of intercontinental
travel. As it were, ditching the helm for a yoke.
2023-11-26 22:23:18 -08:00
Antonio Gurgel
0529bdf6a2 Update my charts; yoke others to nixhelm
By overlaying nixhelm's charts with those I use for myself, be they
behind nixhelm's or simply absent, I get the best of both worlds.
2023-11-25 00:33:44 -08:00
Antonio Gurgel
1444cb9b18 s/release/service/g
"Helm releases" is what I'd been terming individual services, but
it makes no sense outside of the internal context of the Helm builder.

I also didn't want to call them "apps", however shorter that term is.
These are not apps.
2023-11-24 17:35:15 -08:00
Antonio Gurgel
dbb65668ee Add Longhorn 2023-11-24 12:27:52 -08:00
Antonio Gurgel
c53071ef67 Tidy up 2023-11-23 10:34:53 -08:00
Antonio Gurgel
61c040df2c Revert silly name for import flake-builders
Also, clean out unused variables.
2023-11-23 10:22:34 -08:00
Antonio Gurgel
ef94817a55 Stop relying on ns/name in derivation path
I've changed release modules' signatures from:
`{lib} -> ... -> <drv>`
to:
`{lib} -> ... -> {out=<drv>; extra=<drv>;}`
Which makes individual derivations more easily findable.

Now, instead of picking them out from a soup of paths in `output.sh`
with a specially-crafted needle (`${ns}-${name}`), I map derivations
directly to paths and use the result as a sort of index. In other words,
I spent some ingenuity in `flake-builders.sh` to save a _lot_ of
ingenuity in `output.sh`.

This affords me the extra convenience, previously spurned because of
the very limitation I've overcome, of symlinking derivations in the
output flake.
2023-11-23 10:07:19 -08:00
Antonio Gurgel
e8016e5bc5 Reflow comments
I try to insert line breaks where a thought fragment ends (a habit
learnt from writing subtitles), but in comments and Git commit
messages it doesn't make as much sense.
2023-11-22 17:54:27 -08:00
Antonio Gurgel
05a3f2bef0 Build extras from system releases too 2023-11-21 23:19:46 -08:00
Antonio Gurgel
6aff849da7 Add kyverno
I have my answer to 2638113, and it's what I was suspecting: the
flake-builder was never using clusterData until I added a release
that needs it, at which point I got the dreaded "error: attribute
'apiVersions' missing".

Remediation was simple: realize the wrongheadedness of passing
an empty attrset when the values are already well-known.
2023-11-21 20:58:13 -08:00
Antonio Gurgel
dc3060aa30 Pass charts into releases, and restore variadity
It doesn't pay to be strict about release module arity.
2023-11-21 20:46:32 -08:00
Antonio Gurgel
1a44fbafd5 Refactor output script to deal with both trees 2023-11-20 23:49:01 -08:00
Antonio Gurgel
b4deb0b258 Implement clusterData
kubelib.buildHelmChart can take the target Kubernetes version and
a list of custom APIs, so I'll bind them both up in an attrset
and pass them to `flake-builder.releases`.

Accordingly, the other release-builders will have to become variadic.
2023-11-20 23:31:11 -08:00
Antonio Gurgel
aa1ec7d842 Don't do readFile twice
Also, I had a brief temptation to move `gatherApis` to `flake-builders`,
but apart from being used in the flake's let-in, it has little in common
with the other builders. I need to lose a direct dependency on kubelib
to try the concept out, though (`flake-builders` doesn't take `kubelib`),
and I ended up keeping the result.
2023-11-20 23:02:54 -08:00
Antonio Gurgel
3e7a376329 Start messy refactor
Release trees are now split into API-producing and API-using ones.
Namespace rake must now take a list of roots of release trees.
2023-11-20 22:46:06 -08:00
Antonio Gurgel
5ec509e3b6 Add packages.*.lib as output (useful for debugging) 2023-11-20 21:52:23 -08:00
Antonio Gurgel
3b5168fdc0 Identify another messy refactor on the horizon
Packages can either output new APIs or expect them in the cluster.

Examples of packages which
- output APIs: Gateway API, which installs various versions of
  gateway.networking.k8s.io resources.
- take APIs as input: app-template, which queries the cluster to
  choose v1a2, v1b1, or v1 for its HTTPRoute (etc.) objects.

("Packages" here collectively refers to Helm charts and YAML bundles.)

I will have to impose strict ordering on them, i.e., build the former
before the latter.
2023-11-20 21:46:44 -08:00
Antonio Gurgel
e5ff9ec805 Factor out pname from main derivation 2023-11-19 14:24:35 -08:00
Antonio Gurgel
708e537c7c Remove verbs from lib.{build,fetch}ers.*
Reading things like `lib.builders.buildHelmChart` got exhausting.
2023-11-19 14:24:24 -08:00
Antonio Gurgel
d0f61ec7de Add Makefile and helper for decrypting SOPS secrets 2023-11-19 13:44:34 -08:00
Antonio Gurgel
33433a953e Build namespaces
I initially thought this would be just another release in
`releases/common/namespaces`, but there's a lot more potential
than that.
2023-11-19 13:21:41 -08:00
Antonio Gurgel
6e09298a02 Tidy up 2023-11-19 11:46:27 -08:00
Antonio Gurgel
408befb503 Decouple homelab idiosyncrasies
My long-term vision for this flake is to use it as a control flake:
plug it into your homelab ("data-plane") flake and avail yourself
of its `lib.builders`, et cetera.

In short, I want this flake to be useful to many people, and that
means not shipping my homelab with it.
2023-11-19 11:35:35 -08:00
Antonio Gurgel
a74676d5f8 Factor out derivation-collecting 2023-11-18 23:22:51 -08:00
Antonio Gurgel
2c213d6222 Factor out (and document exhaustively) flake-builders 2023-11-18 23:13:11 -08:00
Antonio Gurgel
f62420754a Lower all of lib's imports into named attrs
The namespace was getting a bit crowded.
2023-11-18 22:38:17 -08:00
Antonio Gurgel
18b3cbfe84 Remove kubelib as release input; rm buildYAMLStream synonym
Everything I need directly from nix-kube-generators is now
handled in `lib/`. Additionally, now that I know buildYAMLStream always
takes a namespace and name, there's no need for the longer-winded name.
2023-11-18 22:21:08 -08:00
Antonio Gurgel
367851267f Split fetchers and builders; create NamespacedYAML builder
The reason I struggled with genericBuilders, and again when I replaced
`remoteYAML`'s NS-name `pname` with `url`, is that I was confusing the
following two things:
1. Things that fetch a resource (a Helm chart, a YAML stream, etc.)
without naming or namespacing it.
2. Things that create a release _by_ giving it a name and namespace
so that lib/output.sh can sort the resultant files into directories.

Additionally, I was questioning the good sense of releases/svc/gateway:
a release with no release, but only extra objects? Turns out I
needlessly bound the concept of JIT namespace injection to that
`extraObjects` feature. Once I abstracted that builder, the more general
solution became clear.
2023-11-18 22:01:43 -08:00
Antonio Gurgel
b97c0cd007 Don't use dir name in .#packages.*.default
https://nix.dev/guides/best-practices#reproducible-source-paths
2023-11-18 19:22:25 -08:00
Antonio Gurgel
8d355af50d Convert releases/svc/gateway to extraObjects
Now that I have the auto-namespace thing I can skip passing `namespace`
into this module too.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
b51bcafdaf Implement attaching extra k8s objects to releases
No more tossing YAMLs into release dirs. All is Nix.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
11a3fcb002 Refactor modules
By declaring builders at the module level, only to call them in
flake.nix, I give myself the opportunity to inject `{name, namespace}`
there and need no longer pass these args into every module myself.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
05604660ea Factor out app-template HTTPRoutes 2023-11-18 02:09:30 -08:00
Antonio Gurgel
f5b9d92e0f Devise way to retrieve Helm values as YAML
Even though I've refactored the values into Nix, I'd like them easily
available as YAML. This is impossible to do inside the flake, because
it requires `nix derivation show`, so I made do with a helper script.
2023-11-18 00:52:31 -08:00
Antonio Gurgel
8a53be1d9f Have devshell follow root nixpkgs; update deps 2023-11-17 23:22:32 -08:00
Antonio Gurgel
1ab0281d9d Build top- and namespace-level Kustomizations
For `kubectl apply -k result`.
2023-11-17 23:09:06 -08:00