<p>we are facing issue while trying to set up <code>activeDeadlineSeconds</code> on Deployment. While we see at kubectl explain, according to that; it is a valid parameter on deployment. Please refer to this image:</p>

<p><a href="https://i.stack.imgur.com/0rY3r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0rY3r.png" alt="enter image description here"></a></p>

<p>Now, when we try to set same parameter to deployment; it say's this is invalid. Please refer to image below:</p>

<p><a href="https://i.stack.imgur.com/lgBGE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lgBGE.png" alt="enter image description here"></a></p>

<p>Please let us know, if we are doing something wrong here. You can use following yaml to do quick experiments:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: test
  name: test
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: test
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
status: {}
</code></pre>

<p>we are trying this because in our case there is an init-container which sometimes hangs, because <code>activeDeadlineSeconds</code> includes init containers too; <code>progressdeadlineseconds</code> doesn't include init containers</p>

<p>Is there an alternative to this?</p>

Prateek Jain
<p>The idea of using <code>activeDeadlineSeconds</code> on a Deployment means that you want to run something that will not last for too long. This goes against the purpose of having a Deployment. A Deployment is meant for things you want to last. </p>

<p>As <a href="https://stackoverflow.com/users/1061413/amit-kumar-gupta" title="11,858 reputation">Amit Kumar Gupta</a> explained: </p>

<blockquote>
  <p>Syntactically, <code>deployment.spec.template.spec</code> is the same as
  <code>pod.spec</code> (which is why you see <code>activeDeadlineSeconds</code> in <code>kubectl
  explain</code> output), but semantically not all the fields in a pod spec
  are meaningful/allowed/supported in the context of a Deployment (which
  is why you’re seeing the forbidden error message — under the hood,
  creating a Deployment results in creating ReplicaSets).</p>
</blockquote>

<p>If we check the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/" rel="nofollow noreferrer">documentation</a> we can see that <code>activeDeadlineSeconds</code> is available for Jobs and Pods only. </p>

<p>Jobs and Pods are meant to run a task and die after if finishes. </p>

<blockquote>
  <p>activeDeadlineSeconds </p>
  
  <p>Specifies the duration in seconds relative to
  the startTime that the job may be active before the system tries to
  terminate it; value must be positive integer</p>
</blockquote>

<p>If you are considering to set <code>activeDeadlineSeconds</code> it means that you don't want you Deployment Pods to last and this is a wrong approach.</p>

<blockquote>
  <p>Is there an alternative to this?</p>
</blockquote>

<p>It really depends on why your application needs this approach. If you really think this approach makes sense, you can open an <a href="https://github.com/kubernetes/kubernetes/issues/new/choose" rel="nofollow noreferrer">issue</a> and make a feature request for this. </p>
