Skip to content

feat(controller): declare environments, groups and pools as kubernetes custom resources - #49

Merged
TheMeinerLP merged 5 commits into
mainfrom
feat/v2-crds
Nov 25, 2026
Merged

TheMeinerLP merged 5 commits into
mainfrom
feat/v2-crds

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Contributor

Problem

Pools, environments and groups could only be declared through the REST API or the CLI. On Kubernetes
that means the platform team cannot keep them in Git next to everything else and let FLUX apply them.

Approach

Three namespaced custom resources (Environment, Group, Pool, grus.onelitefeather.net/v1alpha1) mirror
the domain specs one to one. With GRUS_CRDS=true (chart: crds.watch) the controller watches its own
namespace, applies every resource with source kubernetes and removes stored objects whose resource is
gone, so the cluster stays the source of truth. Deleting a pool resource drains the pool like the API does.

The outcome comes back to the user on the resource: invalid specs show Ready=False with reason Invalid
and the field messages, pools report replicas, ready and allocated replicas and whether they reached their
minimum. Objects owned by Kubernetes stay read-only in the REST API; the 409 now says which resource to edit
with kubectl.

The chart does not install the CRDs (FLUX ships deploy/crds); with crds.watch it only adds namespaced
read rights and status write rights to the existing Role. No ClusterRole.

Testing

  • Unit tests with the fake dynamic client and informers: initial apply, pruning of stale objects (but not of
    API-owned ones), invalid and mistyped specs, status counts, debounce and condition times with an injected
    clock, add/delete events, retry of failed applies. No sleeps.
  • A schema test compares every JSON field of the three specs with the CRD schemas in both directions, and
    the example resources are decoded strictly and validated.
  • helm lint and helm template with and without crds.watch.
  • Not tested against a real cluster.

@TheMeinerLP
TheMeinerLP merged commit 7055f78 into main Nov 25, 2026
5 checks passed
@TheMeinerLP
TheMeinerLP deleted the feat/v2-crds branch November 25, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant