Skip to content

CICD-278 · Kubernetes Job execution ​

Encyclopedia · Advanced Kubernetes operations · All snippets

Previous · CICD-277 · Next · CICD-279

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 RUN_ID.

2. Copy the snippet ​

bash
kubectl -n staging create job "smoke-${RUN_ID:?}" --from=cronjob/smoke
kubectl -n staging wait --for=condition=complete "job/smoke-$RUN_ID" --timeout=120s
kubectl -n staging logs "job/smoke-$RUN_ID"

3. How it works ​

A known CronJob provides the Job template. The workflow waits for the generated Job to complete and reads its logs as evidence.

4. Verify the result ​

Use a fresh run ID, a trusted CronJob and bounded job TTL. Inspect logs if completion times out.

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