'JOB_COMPLETION_INDEX environment variable is empty when submitting an Indexed Job to kubernetes
I've made my cluster using minukube.
as I know, Indexed-Job feature is added at kubernetes version 1.21.
but when I made my job, it looks like there is no $JOB_COMPLETION_INDEX environ variable.
here is my yaml
apiVersion: batch/v1
kind: Job
metadata:
name: my-job
spec:
parallelism: 2
completions: 2
completionMode: Indexed
template:
spec:
restartPolicy: Never
containers:
- name: 'my-container'
image: 'busybox'
command: [
"sh",
"-c",
"echo My Index is $JOB_COMPLETION_INDEX && sleep 3600",
]
$ job.batch/my-job created
but as I mentioned before, it looks like the job is NOT Indexed-Job
below is logs of my pods(controlled by my-job)
$ kubectl logs pod/my-job-wxhh6
My Index is
$ kubectl logs pod/my-job-nbxkr
My Index is
It seems that the $JOB_COMPLETION_INDEX environ variable is empty.
I'll skip it to make it brief, but when I directly accessed the container, there is also no $JOB_COMPLETION_INDEX.
and below is result of kubectl describe job.batch/my-job
command
Name: my-job
Namespace: default
Selector: controller-uid=6e8bda0c-f1ee-47b9-95ec-87419b3dfaaf
Labels: controller-uid=6e8bda0c-f1ee-47b9-95ec-87419b3dfaaf
job-name=my-job
Annotations: <none>
Parallelism: 2
Completions: 2
Start Time: Sat, 28 Aug 2021 03:56:46 +0900
Pods Statuses: 2 Running / 0 Succeeded / 0 Failed
Pod Template:
Labels: controller-uid=6e8bda0c-f1ee-47b9-95ec-87419b3dfaaf
job-name=my-job
Containers:
my-container:
Image: busybox
Port: <none>
Host Port: <none>
Command:
sh
-c
echo My Index is $JOB_COMPLETION_INDEX && sleep 3600
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 100s job-controller Created pod: my-job-wxhh6
Normal SuccessfulCreate 100s job-controller Created pod: my-job-nbxkr
there is no annotation. as document, batch.kubernetes.io/job-completion-index
annotation must be there.
My version is upper than kubernetes 1.21, where the Indexed-Job feature is introduced.
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T21:04:39Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:53:14Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
$ minukube kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:59:11Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:53:14Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
What should I do?
Solution 1:[1]
as of now(2021.08.29), the IndexedJob is an alpha feature, so I started minikube with feature-gates flag
minikube start --feature-gates=IndexedJob=true
and It works well
Solution 2:[2]
The documentation is incorrect; you need to be on the rapid release channel, at least version 1.22.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Seyoon |
Solution 2 | Tudor Achim |