CICD-156 · Observe container restart count
Encyclopedia · Kubernetes fundamentals · All snippets
Previous · CICD-155 · Next · CICD-157
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.
2. Copy the snippet
bash
kubectl -n staging get pod -l app=web -o json | jq -e '[.items[].status.containerStatuses[]?.restartCount] | length>0 and all(. == 0)'3. How it works
The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate. The command archives or inspects the selected files. Verify the relative paths and file set before using the archive downstream.
4. Verify the result
Restrict to a newly deployed test workload. Historical restarts may be intentional in other contexts.
Validation syntax-validated (Bash parse). Status definitions.