<p>We're using Openshift (a managed version of Kubernetes) and I'm struggling to set the pod restart policy from 'Always' to 'Never' for all pods created by our deployment config, but I'm not sure where in the yaml to make this change.</p>
<p>Our deployment config looks something like:</p>
<pre><code>kind: DeploymentConfig
metadata:
  generation: 19
  name: my-deployment-config
  namespace: my-deployment-config-namespace
  selfLink: &gt;-
    ...
  uid: af918183-c780-11ea-8945-525400d3e4d9
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    name: my-selector
  strategy:
    activeDeadlineSeconds: 21600
    resources: {}
    rollingParams:
      intervalSeconds: 1
      maxSurge: 25%
      maxUnavailable: 25%
      timeoutSeconds: 600
      updatePeriodSeconds: 1
    type: Rolling
template:
    metadata:
      ...
    spec:
      containers:
        - image: &gt;-
            (image source)
          imagePullPolicy: Always
          name: my-container
          ports:
            - containerPort: 8080
              protocol: TCP
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
</code></pre>
<p>When I try to change restartPolicy there from 'Always' to 'Never', I'm met with</p>
<blockquote>
<p>Failed to process the resource. Reason:
DeploymentConfig.apps.openshift.io
&quot;my-deployment-config&quot; is invalid:
spec.template.spec.restartPolicy: Unsupported value: &quot;Never&quot;:
supported values: &quot;Always&quot;</p>
</blockquote>
<p><a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy" rel="noreferrer">The Kubernetes documentation</a> as well as the <a href="https://docs.openshift.com/container-platform/3.11/architecture/core_concepts/pods_and_services.html#admin-manage-pod-restart" rel="noreferrer">Openshift documentation</a> on restart policy shows that pods can be configured with Always, Never, or OnFailure.</p>
<p>So how do I do that from a deployment config?</p>

b15
<p>Deployments allow only Always for the restartPolicy.  Refer this documentation <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#pod-template" rel="noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#pod-template</a></p>
<p>Also refer the issue report long back regarding the same.
<a href="https://github.com/kubernetes/kubernetes/issues/24725" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/24725</a></p>
<p>Only a .spec.template.spec.restartPolicy equal to Always is allowed, which is the default if not specified.</p>
<p>Note: Is the same case for DaemonSets, ReplicaSets, ReplicationController.</p>
