Kubernetes为重启策略使用了错误的值

时间:2018-08-27 17:21:49

标签: kubernetes kubectl

我正在尝试使用以下配置在kubernetes中进行Job部署,但出现此错误:

spec.template.spec.restartPolicy: Unsupported value: "Always": supported values: OnFailure, Never

就像kubernetes无法读取我的restartPolicy配置(设置为Never)或在某个地方被覆盖...

“有趣”的事情是它对我的Cronjob部署有效(我对他们使用相同的模板)。

Kubernetes版本:1.7.7

这是我的配置:

{
  "apiVersion": "batch/v1",
  "kind": "Job",
  "metadata": {
    "name": "pipeline-test",
    "labels": {
      "app": "pipeline-test",
      "env": "test",
      "commit": "xxxxxxxx"
    },
    "namespace": "pipeline-test"
  },
  "spec": {
    "jobTemplate": {
      "spec": {
        "template": {
          "metadata": {
            "labels": {
              "app": "pipeline-test",
              "env": "test",
              "commit": "xxxxxxxx"
            }
          },
          "spec": {
            "restartPolicy": "Never",
            "containers": [
              {
                "name": "pipeline-test",
                "image": "us.gcr.io/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                "env": [
                  {
                    "name": "APP_ENV",
                    "value": "test"
                  },
                  {
                    "name": "MAX_WORKERS",
                    "value": "2"
                  },
                  {
                    "name": "TYPE_CASTING",
                    "value": "false"
                  },
                  {
                    "name": "ENV",
                    "value": "test"
                  },
                  {
                    "name": "PROJECT_NAME",
                    "value": "null-testing1-v"
                  },
                  {
                    "name": "JOB_NAME",
                    "value": "testjob"
                  },
                  {
                    "name": "SUBSCRIPTION_NAME",
                    "value": "testsub"
                  },
                  {
                    "name": "CACHE_INVALIDATOR",
                    "value": "14-1"
                  },
                  {
                    "name": "GIT_COMMIT",
                    "value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                  },
                  {
                    "name": "APP_GIT_COMMIT",
                    "value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                  },
                  {
                    "name": "APP_NAME",
                    "value": "pipeline-test"
                  },
                ],
                "volumeMounts": [

                ],
                "ports": [
                  {
                    "containerPort": 3000
                  }
                ],
                "resources": {
                  "requests": {
                    "cpu": "100m",
                    "memory": "512Mi"
                  },
                  "limits": {
                    "cpu": "1000m",
                    "memory": "512Mi"
                  }
                }
              }
            ],
            "volumes": [

            ],
            "imagePullSecrets": [
              {
                "name": "image-pull-secret"
              }
            ]
          }
        }
      }
    }
  }
}

谢谢

编辑:我可以通过删除2行来运行它:

    "jobTemplate": {
      "spec": {

因此,restartPolicy在json中处于错误的级别,并且未被读取。

1 个答案:

答案 0 :(得分:2)

我能够通过删除2行来运行它:

https://<restApiId>.execute-api.<region>.amazonaws.com/<stageName>

因此,restartPolicy在json中处于错误的级别,并且未被读取。