Skip to content

CICD-279 · Kubernetes CronJob deployment ​

Encyclopedia · Advanced Kubernetes operations · All snippets

Previous · CICD-278 · Next · CICD-280

1. Where it fits ​

  • Placement manifests/health-cronjob.yaml.
  • Prerequisites kubectl, isolated cluster or namespace and installed CRDs when named.
  • Platforms kubernetes, local-lab.

2. Copy the snippet ​

yaml
apiVersion: batch/v1
kind: CronJob
metadata: {name: smoke}
spec:
  schedule: "17 * * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      activeDeadlineSeconds: 60
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: probe
              image: curlimages/curl:8.12.1
              args: ["--fail", "--max-time", "5", "http://web/healthz"]

3. How it works ​

API version decides which schema and controller can accept the resource. Check the corresponding kind and availability on the target cluster.

4. Verify the result ​

Apply in the same namespace as Service web. Verify one scheduled successful Job and pin the tested image digest for repeatability.

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