<p>In the <code>create_namespaced_job</code> method there is no parameter that exists to define <code>preStop</code> and <code>postStart</code> handlers.</p>
<pre><code>V1Job create_namespaced_job(namespace, body, pretty=pretty, dry_run=dry_run, field_manager=field_manager)
</code></pre>
<p><a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/BatchV1Api.md#create_namespaced_job" rel="nofollow noreferrer">Source</a>.</p>
<p>So, how to add these life-cycle handlers to a job or pod by Python Kubernetes?</p>

<blockquote>
<p>In the create_namespaced_job method there is no parameter that exists to define preStop and postStart handlers.</p>
</blockquote>
<p>The <code>preStop</code> and <code>postStart</code> handlers exists on the containers. You linked to the documentation for <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/BatchV1Api.md#create_namespaced_job" rel="nofollow noreferrer">create_namespaced_job</a> and the parameter <code>body</code> is a <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Job.md" rel="nofollow noreferrer">V1Job</a>, and the <code>spec</code> of that has a <code>template</code>, that has a <code>spec</code> of type <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1PodSpec.md" rel="nofollow noreferrer">V1PodSpec</a> and there you find a field <code>container[list]</code>and there you find a field <code>lifecycle</code> of type <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Lifecycle.md" rel="nofollow noreferrer">V1Lifecylce</a> that has the <code>preStop</code> and <code>postStart</code>-handlers.</p>
<p>The documentation can also be navigated with <code>kubectl explain</code>, e.g:</p>
<pre><code>kubectl explain podTemplate.template.spec.containers.lifecycle
</code></pre>
