Kubernetes · FinOps
One Reusable Plan/Apply Workflow for Cost-Optimised Autoscaling
A shared workflow registers clusters and applies autoscaling policy, parameterised by environment, HA role and state suffix: spot in lower, on-demand in upper.
// Overview
Thin wrappers for teams and customers (lower, upper, HA primary and secondary) call one reusable workflow with a plan job followed by a gated apply job. Policy is read from Vault: lower uses spot capacity, upper on-demand; CPU, memory, disk and pod limits are set; evictor and weekly node rotation are Vault-controlled.
// The problem
Node scaling and cost tuning has to be consistent and re-runnable across many clusters and two environments without duplicating workflow logic.
// Flow
- Wrapper preparedetermine environments and subscriptions; check the required flag
- Matrix of jobslower, upper, lower-secondary, upper-secondary, with paired skip jobs
- Plan jobfederated auth, templated backend with state suffix, fmt, init, validate, lint, scan
- Plan artifactmarkdown summary and raw plan uploaded; optional chat notification
- Gate: changes only gateapply runs only if the plan has changes and the action allows
- Apply or destroythe exact saved plan is applied
- Chain onwardTerraform dispatches the GitOps bootstrap
// Design decisions & guardrails
- Applying the saved plan artifact guarantees that what was reviewed is what runs.
- A state-suffix input separates HA secondary state; an is-secondary flag adjusts behaviour such as the evictor.
- Auth method is an input (admin or RBAC) for clusters with local accounts disabled.
- Evictor, rotation schedule and zones are all Vault-driven with documented defaults.
- The earlier GCP generation did the same with a read-only mode and a GPU toggle.
// Outcome
Documented limits such as 2 to 200 CPU cores autoscaling, with one workflow serving every cluster shape.