feat(orchestration): targets from target.yaml, guided run, several clusters #1

Merged
crapougnax merged 3 commits from feat/orchestration-engine into develop 2026-11-06 20:18:21 +00:00
Member

Replaces the shell placeholder of @tycho/orchestration with the engine of RFC-001 §3: a Kubernetes target described by target.yaml, built and kept up to date by a guided, resumable run. One tycho manages several targets.

What it does

  • target.yaml: types and fail-fast validation. Every problem is listed at once; no default for instance values (publicIps, egressGateway, Kubernetes version…); placeholders (example.com, TODO) and branch refs are refused.
  • Contexts: context add|use|list|remove, --target, TYCHO_TARGET. Never guesses. One kubeconfig per target (0600, ~/.config/tycho/orchestration/kube/), always passed explicitly to kubectl.
  • Catalogues fetched at a pinned ref (tag or commit) into a cache; exactly one provides the infra recipe (Terraform modules).
  • Terraform roots generated as JSON from the catalogue modules, two states per target: public-ips (durable, prevent_destroy in the module) and cluster (network, egress gateway on the reserved IP, Kapsule, free list of pools incl. GPU/taints/scale-to-zero, extra modules from spec.infra.modules).
  • Guided run (apply): public IPs → DNS (stops with exit 3 and the list of records until public resolvers return them) → reverse DNS → cluster → kubeconfig + ownership marker → stacks in requires order. State in .tycho/journal.json of the target repository.
  • Stacks: kubectl kustomize, then ${VARIABLE} substitution limited to declared and built-in names (other ${...} untouched); secrets only from SOPS (secrets.enc.yaml).

Guards

  • Saved plans only; any destroy or replace refused; confirmation before each apply (--yes for CI).
  • Before every kubectl change, the ConfigMap kube-system/tycho-target must match the target name and cluster id.

Checks

  • bun test: 14 tests (validation, roots, plan summary, DNS records, stack order and values, substitution, contexts).
  • tsc --noEmit OK.
  • Generated roots pass terraform validate against the real catalogue modules fetched from qtrn-io/cluster at a pinned commit.
  • CLI exercised through index.js (run(args, ctx)): contexts, validate, status, plan stops cleanly without credentials.

Not yet

Ephemeral IPs, providers other than Scaleway, Podman, tycho render (Argo CD CMP), cost in the plan. Version left at 0.1.0: the release number is decided at release time.

🤖 Generated with Claude Code

Replaces the shell placeholder of `@tycho/orchestration` with the engine of RFC-001 §3: a Kubernetes target described by `target.yaml`, built and kept up to date by a guided, resumable run. One `tycho` manages several targets. ## What it does - **`target.yaml`**: types and fail-fast validation. Every problem is listed at once; no default for instance values (`publicIps`, `egressGateway`, Kubernetes version…); placeholders (`example.com`, `TODO`) and branch refs are refused. - **Contexts**: `context add|use|list|remove`, `--target`, `TYCHO_TARGET`. Never guesses. One kubeconfig per target (0600, `~/.config/tycho/orchestration/kube/`), always passed explicitly to kubectl. - **Catalogues** fetched at a pinned ref (tag or commit) into a cache; exactly one provides the `infra` recipe (Terraform modules). - **Terraform roots** generated as JSON from the catalogue modules, two states per target: `public-ips` (durable, `prevent_destroy` in the module) and `cluster` (network, egress gateway on the reserved IP, Kapsule, free list of pools incl. GPU/taints/scale-to-zero, extra modules from `spec.infra.modules`). - **Guided run** (`apply`): public IPs → DNS (stops with exit 3 and the list of records until public resolvers return them) → reverse DNS → cluster → kubeconfig + ownership marker → stacks in `requires` order. State in `.tycho/journal.json` of the target repository. - **Stacks**: `kubectl kustomize`, then `${VARIABLE}` substitution limited to declared and built-in names (other `${...}` untouched); secrets only from SOPS (`secrets.enc.yaml`). ## Guards - Saved plans only; any destroy or replace refused; confirmation before each apply (`--yes` for CI). - Before every kubectl change, the ConfigMap `kube-system/tycho-target` must match the target name and cluster id. ## Checks - `bun test`: 14 tests (validation, roots, plan summary, DNS records, stack order and values, substitution, contexts). - `tsc --noEmit` OK. - Generated roots pass `terraform validate` against the real catalogue modules fetched from `qtrn-io/cluster` at a pinned commit. - CLI exercised through `index.js` (`run(args, ctx)`): contexts, validate, status, plan stops cleanly without credentials. ## Not yet Ephemeral IPs, providers other than Scaleway, Podman, `tycho render` (Argo CD CMP), cost in the plan. Version left at 0.1.0: the release number is decided at release time. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Replaces the shell placeholder with the engine of RFC-001 §3:
- target.yaml: types and fail-fast validation (every problem listed, no
  default for instance values, placeholders and branch refs refused);
- contexts: one tycho manages several targets (context add/use/list,
  --target, TYCHO_TARGET); one kubeconfig per target, 0600, outside the repo;
- catalogues fetched at a pinned ref; Terraform roots generated from the
  catalogue modules: durable public IPs and cluster, each in its own state;
- guided run: public IPs, stop until DNS records exist, reverse DNS, cluster,
  kubeconfig and ownership marker, stacks in requires order;
- guards: saved plans only, any destroy or replace refused, confirmation
  before each apply, cluster ownership checked before every kubectl change;
- stacks: ${VARIABLE} substitution limited to declared and built-in names,
  secrets only from SOPS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Member

Pushed refactor(orchestration): targets come from the core: contexts moved to the core (tycho/tycho PR feat/contexts). The module now acts on ctx.target handed over by the core and refuses non-kubernetes targets. Tested end to end with the compiled core: tycho module link, tycho context add/use, --target, TYCHO_TARGET.

Pushed `refactor(orchestration): targets come from the core`: contexts moved to the core (tycho/tycho PR feat/contexts). The module now acts on `ctx.target` handed over by the core and refuses non-kubernetes targets. Tested end to end with the compiled core: `tycho module link`, `tycho context add/use`, `--target`, `TYCHO_TARGET`.
Targets are now registered and selected by the Tycho core (tycho context,
--target, TYCHO_TARGET). The module acts on the target it receives and
refuses one whose engine is not kubernetes; it keeps only its local state
(kubeconfigs, catalogue cache). init prints the tycho context command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- stacks are built with --enable-helm, by the standalone kustomize when
  installed (the kustomize embedded in kubectl calls `helm version -c`,
  removed in Helm 4), else by kubectl;
- tycho.modePath lets a recipe keep its variants elsewhere than
  <path>/overlays/<mode> (e.g. one directory per environment).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crapougnax merged commit 75d9e88827 into develop 2026-11-06 20:18:21 +00:00
crapougnax deleted branch feat/orchestration-engine 2026-11-06 20:18:21 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tycho/modules!1
No description provided.