CICD-146 · Verify Kubernetes client and server context
Encyclopedia · Kubernetes fundamentals · All snippets
Previous · CICD-145 · Next · CICD-147
1. Where it fits
- Placement Bash run step following checkout, or equivalent lab terminal.
- Prerequisites isolated Kubernetes namespace, kubectl and reviewed manifests.
- Platforms kubernetes, local-lab.
- Parameters
EXPECTED_CONTEXT.
2. Copy the snippet
bash
kubectl version
test "$(kubectl config current-context)" = "${EXPECTED_CONTEXT:?}"3. How it works
The shell predicate makes the expected state explicit and returns a nonzero status when it is not satisfied.
4. Verify the result
Scope commands to the verified environment. Prevent writes if the context drifts.
Validation syntax-validated (Bash parse). Status definitions.