<p>Hi i created a node app that creates a k8s job with kubernetes-client library. Then that job app responds back with a HTTP call to my node app. to reduce network latency and timing, i have to put everything inside a cluster. Is this possible to create a job inside a deployment?</p>
<p>References: <a href="https://github.com/kubernetes-client" rel="nofollow noreferrer">https://github.com/kubernetes-client</a></p>
<pre><code>   apiVersion: batch/v1
   kind: Job
   metadata:
     name: job
   spec:
     ttlSecondsAfterFinished: 10
     template:
       spec:
         containers:
         - name: samplejob
           image: gcr.io/hjgfjfhgffghfght
           command: [&quot;node&quot;,  &quot;index.js&quot;, '{api_url&quot;:&quot;apienpoint&quot;}']
           resources:
             limits:
               memory: &quot;128Mi&quot;
               cpu: &quot;100m&quot;
             requests:
               memory: &quot;128Mi&quot;
               cpu: &quot;100m&quot;
         restartPolicy: Never
     backoffLimit: 1
</code></pre>

Imrahamed
<p>This is definitely possible. It all depends on how you create your node.js container image. Your application can run as a deployment within the cluster. Something will cause the application to trigger an event. That event will send an API call to the k8s master to request that a job be created.</p>

<p>You can use one of the <a href="https://kubernetes.io/docs/reference/using-api/client-libraries/" rel="nofollow noreferrer">client libraries</a> to interface with the k8s master. The node.js library is maintained by the community.</p>
