<p>I have a python script and I used on Kubernetes.
After process ended on python script Kubernetes restart pod. And I don't want to this.</p>
<p>I tried to add a line of code from python script like that:</p>
<pre><code>text = input(&quot;please a key for exiting&quot;)
</code></pre>
<p>And I get EOF error, so its depends on container has no EOF config on my Kubernetes.</p>
<p>After that I tried to use restartPolicy: Never. But restartPolicy is can not be Never and I get error like that:</p>
<pre><code>error validating data: ValidationError(Deployment.spec.template): unknown field \&quot;restartPolicy\&quot; in io.k8s.api.core.v1.PodTemplateSpec;
</code></pre>
<p>How can I make this? I just want to no restart for this pod. Its can be on python script or Kubernetes yaml file.</p>

akasaa
<p>You get <code>unknown field \&quot;restartPolicy\&quot; in io.k8s.api.core.v1.PodTemplateSpec;</code> because you most probably messed up some indentation.</p>
<p>Here is an example deploymeny with <strong>incorrect indentation</strong> of <code>restartPolicy</code> field:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
    restartPolicy: Never   # &lt;-------
</code></pre>
<hr />
<p>Here is a deploymet with <strong>correct indentation</strong>:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
      restartPolicy: Never   # &lt;-------
</code></pre>
<p>But this will result in error:</p>
<pre><code>kubectl  apply -f deploy.yaml
The Deployment &quot;nginx-deployment&quot; is invalid: spec.template.spec.restartPolicy: Unsupported value: &quot;Never&quot;: supported values: &quot;Always&quot;
</code></pre>
<p>Here is an explaination why: <a href="https://stackoverflow.com/questions/55169075/restartpolicy-unsupported-value-never-supported-values-always">restartpolicy-unsupported-value-never-supported-values-always</a></p>
<hr />
<p>If you want to run a one time pod, use a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="nofollow noreferrer">k8s job</a> or use pod directly:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    run: ngx
  name: ngx
spec:
  containers:
  - image: nginx
    name: ngx
  restartPolicy: Never
</code></pre>
