<p>I'm trying a Job deployment in kubernetes with the configuration below but I'm getting this error :</p>

<pre><code>spec.template.spec.restartPolicy: Unsupported value: "Always": supported values: OnFailure, Never
</code></pre>

<p>It's like kubernetes doesn't read my restartPolicy configuration (set to never) or it's overridden somewhere...</p>

<p>The "funny" thing is it's working for my Cronjob deployment (I'm using the same template for both of them).</p>

<p>Kubernetes version : 1.7.7</p>

<p>Here is my configuration :</p>

<pre><code>{
  "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"
              }
            ]
          }
        }
      }
    }
  }
}
</code></pre>

<p>Thanks</p>

<p>EDIT : I was able to run it by removing 2 lines :</p>

<pre><code>    "jobTemplate": {
      "spec": {
</code></pre>

<p>And so the restartPolicy was at the wrong level in the json and wasn't read.</p>

Skullone
<p>I was able to run it by removing 2 lines :</p>

<pre><code>"jobTemplate": {
  "spec": {
</code></pre>

<p>And so the restartPolicy was at the wrong level in the json and wasn't read.</p>
