Skip to content

CICD-290 · Multi-cluster deployment ​

Encyclopedia · Advanced Kubernetes operations · All snippets

Previous · CICD-289 · Next · CICD-291

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites kubectl, isolated cluster or namespace and installed CRDs when named.
  • Platforms kubernetes, local-lab.
  • Parameters PRIMARY_CONTEXT, SECONDARY_CONTEXT.

2. Copy the snippet ​

bash
for context in "${PRIMARY_CONTEXT:?}" "${SECONDARY_CONTEXT:?}"; do kubectl --context "$context" -n staging apply --dry-run=server -f manifests/ || exit 1; done

3. How it works ​

The loop preflights every named cluster with server-side dry run. A failing context ends the loop before any independent rollout stage starts.

Both targets must accept the rendered manifest at admission time.

flowchart TD
  N1["Reviewed manifests"]
  N2["Primary dry run"]
  N1 --> N2
  N3["Secondary dry run"]
  N2 --> N3
  N4{"Both preflights passed"}
  N3 --> N4
  N5["Proceed to separate rollout"]
  N4 -->|Yes| N5
  N6["Stop"]
  N4 -->|No| N6

4. Verify the result ​

Preflight both clusters before progressive rollout. Order changes and smoke-test each context independently.

Validation syntax-validated (Bash parse). Status definitions.