<p>Given a Kubernetes pod with a yaml as shown below, are there any way to set up the value of the terminationGracePeriodSeconds according to some global/internal variable of the application being executed.</p>
<p><a href="https://i.stack.imgur.com/h0shH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h0shH.png" alt="enter image description here" /></a></p>
<p>Otherwise said and more generally, I know that through downward API, data from the infrastructure/kubernetes (IP, host, …) can be exposed to the application. On the other side, are there any method to expose internal application data/variables to the infrastructure i.e. Kubernetes.</p>

Mazen Ezzeddine
<p>This sort of configuration is exactly what tools like <a href="https://helm.sh" rel="nofollow noreferrer">Helm</a> are good for.  You could configure a Helm chart with a value:</p>
<pre class="lang-yaml prettyprint-override"><code># charts/my-app/values.yaml

# terminationWait specifies the time to wait for a process to exit
# before forcibly killing the container.
terminationWait: 60
</code></pre>
<p>And then reference that value in your YAML manifests:</p>
<pre class="lang-yaml prettyprint-override"><code># charts/my-app/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      terminationGracePeriodSeconds: {{ .Values.terminationWait }}
</code></pre>
<p>More generally it uses the Go <a href="https://pkg.go.dev/text/template" rel="nofollow noreferrer">text/template</a> language, with a large set of extensions, so it's possible to do almost anything with this setup, though it's easiest and clearest to stick with simple value substitution like what's shown here.</p>
