Skip to main content

Lifecycle and scale

Change
The hard part of Day 2 is doing it in the right order

Upgrading a component is rarely hard. Knowing what depends on it, what has to move first, what proves it worked and how to get back is the hard part — and that is exactly what a graph can answer.

a recipe is data, not code · new coverage = one new entrypreflightHEALTHY FIRST?migrationsONLY WHERE NEEDEDapplyGRAPH CHANGE + BUILDverifyTHE COMPONENT'S TESTSdoneNEW VERSION RUNSunhealthy → stop · an upgrade would hide the causefails → revert and rebuild
An upgrade is a recipe, not a script: check health first, migrate only between the right versions, apply as a graph change, verify with the component's own tests — and revert and rebuild if they fail.

Upgrades and migrations​

Each component's upgrade procedure is a recipe: declarative data, not code. Adding coverage for a component means adding an entry, never writing new logic.

Part of a recipeWhat it holds
Version fieldsWhich attributes actually carry the version
PreflightProbes that must pass before anything is touched, each with the risk of proceeding anyway — starting with "is this component healthy right now", because upgrading something already broken hides the cause
MigrationsConditional steps that apply only between specific versions, each with its reverse
ApplyChange the attribute on the graph, then build — never a hand-patched cluster
VerifyThe component's own tests, run after
RollbackRevert the manifests, rebuild
Known gapsWhat the template does not yet handle, stated rather than discovered

The lifecycle tool reports status and produces a plan: the current versions, the dependents that will be affected, the preflight results, and the ordered steps. The AI proposes it; you approve it; the platform performs it as an ordinary graph change.

Database migrations​

Schema migration is an attribute of your application component, migration_command, so it is part of the declared system and moves with it. It runs as an init container named migrate, with the application's own image, environment and security context, before the application container of every new pod. The rollout replaces one pod at a time and never runs more pods than declared (maxSurge: 0), so the migration runs before the first new pod serves, and a failing migration stops the rollout with the old pods still serving — it fails closed rather than starting an application against a half-migrated database.

Backups stay with whatever already owns them — a migration step does not invent its own backup mechanism next to the one that is already proven.

Autoscaling from real signals​

Autoscaling is driven by what the system actually reports, not only by CPU. Scale targets are declared as sub-components of the autoscaler, each bound to a signal:

a metrics querya log queryinference load on a served modelqueue depth

Because the autoscaler is a component and its triggers are sub-components, scaling behaviour is versioned with the stack and visible in a diff — not a cluster-side object someone edited once.

What each KEDA link scales:

On the graphWhat is generated
keda-prometheus, plus a prometheus_query sub-component linked prometheus_query-<app>A ScaledObject on the application, driven by the sub-component's query. The application runs with its own hpa off
keda-topic, keda-queueScales the consumers of a Kafka topic on their lag, or of a RabbitMQ queue on its length or message rate (the link's keda_queue_mode). A topic that sinks through Kafka Connect also scales the Connect workers
keda-db, keda-mongo_dbA scaler on the database itself, driven by a query: for CloudNativePG the cluster's instance count, for MongoDB its workload
keda-modelScales a served model's vLLM runtime
With a prometheus-keda linkAlert rules on KEDA itself

When Argo CD manages a scaled component, its replica count is left to KEDA and not reverted from git — see argocd_replicas_mode in Build and deploy. Under Argo CD, replacing a scaler takes two builds: remove the old one in the first, add the new one in the second, because KEDA refuses a scaler for a workload another scaler still manages.

Load tests​

The k6 component runs load tests as declared state. Each endpoints sub-component is one suite: either a list of targets hit at random, or a journey — one declared account per virtual user, a login, then the steps in order — with k6's own stages and thresholds.

WhatHow
Run a suitekubectl create -f day2/tests/<suite>.yaml. Each create is a new run; nothing runs with the deploy
Schedule a suiteGive it a schedule (a cron expression): a CronJob creates the same run on time
Test a data serviceLink k6 to a database or another data service; a test script per linked service is generated
Read the resultsWith prometheus-k6, every run writes its metrics while it runs, each series labelled with the suite (testid) and the journey step (step). A Grafana linked to that Prometheus shows the k6 dashboards, the KEDA scalers during the test, and what the scaled workloads cost at the prices you type into the dashboard

Remember the gateway: a route's rate limit counts per client address, and every virtual user of a run comes from the same runner pod.

Restart on change​

A generated secret or configuration value that changes must actually reach the running pod. Two complementary mechanisms exist, and both are part of the graph:

Generation-timeContent checksums

The build adds a checksum of exactly the secrets and configuration a workload references to its pod template. Change the value, regenerate, apply — the pod template changed, so the workload rolls. Nothing else does.

RuntimeA reload controller

The Reloader component watches labelled secrets and configuration and restarts the workloads that consume them. It needs no link, and its restarts are invisible to Argo CD's diff, so the two never fight.

Without one of these, a changed secret sits correctly in the API server while the running pod keeps the old value — which is the class of bug that produces "it works after I restart it by hand".

Queueing and priority​

Batch and training workloads can be admitted through a queue rather than competing for whatever the cluster has left. Jobs are labelled into a queue automatically, and priority is expressed as an attribute on the workload that needs it.

This is what makes a shared cluster usable for both a production application and heavy periodic work, without either one starving the other.

Everything here is a graph change​

The common thread: none of these are cluster-side operations you perform and then have to remember. Each one is an attribute or a sub-component on the graph. It is versioned, diffable, duplicable into another environment, rollback-able with the rest of the system, and computable — which is why an AI can plan it safely and why a human can approve it in one look.