0

我已经使用 minukube 制作了我的集群。

据我所知,索引作业功能是在 kubernetes 版本1.21中添加的。

但是当我完成工作时,似乎没有 $JOB_COMPLETION_INDEX 环境变量。

这是我的 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

但正如我之前提到的,看起来这份工作不是索引工作

下面是我的豆荚的日志(由我的工作控制)

$ kubectl logs pod/my-job-wxhh6
My Index is
$ kubectl logs pod/my-job-nbxkr
My Index is

$JOB_COMPLETION_INDEX环境变量似乎为空。

我将跳过它以使其简短,但是当我直接访问容器时,也没有 $JOB_COMPLETION_INDEX。

以下是kubectl describe job.batch/my-job 命令的结果

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

没有注释。作为文档batch.kubernetes.io/job-completion-index注释必须存在。

我的版本高于 kubernetes 1.21,其中引入了 Indexed-Job 功能。

$ 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"}

我应该怎么办?

4

2 回答 2

2

截至目前(2021 年 8 月 29 日),IndexedJob是一个 alpha 功能,所以我使用功能门标志启动了 minikube

minikube start --feature-gates=IndexedJob=true

它运作良好

于 2021-08-28T16:54:40.537 回答
0

文件不正确;您需要在快速发布频道上,至少是 1.22 版。

于 2021-11-29T18:44:38.390 回答