Skip to content

Instantly share code, notes, and snippets.

@hideojoho
Created December 14, 2021 11:28
Show Gist options
  • Save hideojoho/d2d992e1723e68cc1135185fdaa344eb to your computer and use it in GitHub Desktop.
Save hideojoho/d2d992e1723e68cc1135185fdaa344eb to your computer and use it in GitHub Desktop.
How to pass JOB_COMPLETION_INDEX to a pod as an environment variable
apiVersion: batch/v1
kind: Job
metadata:
name: indexed-job
spec:
completions: 5
parallelism: 3
completionMode: Indexed
template:
spec:
restartPolicy: Never
containers:
- name: worker
image: foo/bar
env:
- name: INDEX-VAL
valueFrom:
fieldRef:
fieldPath: metadata.annotations['batch.kubernetes.io/job-completion-index']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment