Architecture

The adept is one controller manager with three reconcilers and one webhook. All of them write with server-side apply and own what they create, so deleting the parent removes it.

Reconciler Watches Creates and owns

ActionManager

Action

One Job per Action, from the job template of the Definition named by spec.type

MaintenanceManager

Maintenance, MaintenanceWindow

One CronJob per Maintenance, which fires its ritual inside the window

VersionManager

Maintenance

Nothing; it writes status.version on the instance’s claim

MaintenanceWindowValidator

MaintenanceWindow (validating webhook)

Nothing; it rejects unusable windows and a second default window

Running an action

  1. The ActionManager resolves the instance namespace. In an instance namespace the Action runs in place. In a claim namespace it reads the claim named by spec.claim, spec.apiVersion and spec.kind, and takes its status.instanceNamespace. Until that resolves, the reason is in status.message and the reconciler retries with backoff.

  2. It reads the Definition named by spec.type in the instance namespace. A missing Definition is final: the Action goes to Failed.

  3. It creates the Job <action>-<type> there and moves the Action to Pending. The Job is owned by the Action only when both live in the same namespace, since Kubernetes rejects owner references across namespaces.

  4. It maps the Job’s status onto the Action: Running, then Succeeded or Failed. Both are final, an Action never runs twice.

A finalizer deletes the Job when the Action is deleted, including one in another namespace.

Maintenance

The MaintenanceManager resolves the window a Maintenance names, or the default window when it names none, and the ritual’s Definition. It writes the CronJob in the instance namespace and reports the schedule it settled on in status.schedule. Instances sharing a window are spread across it by a hash of the Maintenance’s namespace/name. See Maintenance per instance and Maintenance windows.

A missing window is retried, because a chart may render the Maintenance before the window exists. A missing ritual is not an error: the schedule is still published and only the CronJob is removed.

Version bumps

The VersionManager moves a managed instance onto the newest version its claim allows, 15 minutes ahead of its maintenance, so the ritual runs against the version it is meant to. It writes the version to the claim’s status.version; chrysopoeia then rolls the instance out.

  • It keys off the Maintenance, which ties an instance namespace to a window. The namespace’s chrysopoeia annotations name the claim.

  • The newest version is the first entry of the spec.version enum in the claim’s CRD, as chrysopoeia generates it.

  • A claim with spec.version set is pinned and left alone.

  • The annotation adept.helmetica.io/bump-now on the Maintenance asks for a bump straight away. Any new value triggers one; the same value again does nothing.

The adept has no rule for writing claims of its own. Claims are generated kinds, so the permission comes from the aggregated ClusterRole chrysopoeia keeps in step with the CRDs it generates.