<p>I have a cli app written in NodeJS [not by me].</p>
<p>I want to deploy this on a k8s cluster like I have done many times with web servers.</p>
<p>I have not deployed something like this before, so I am in a kind of a loss.</p>
<p>I have worked with dockerized cli apps [like Terraform] before, and i know how to use them in a CICD.</p>
<p>But how should I deploy them in a pod so they are always available for usage from another app in the cluster?</p>
<p>Or is there a completely different approach that I need to consider?</p>
<p>#EDIT#</p>
<p>I am using this in the end of my Dockerfile ..</p>
<pre><code># the main executable
ENTRYPOINT [&quot;sleep&quot;, &quot;infinity&quot;]
# a default command
CMD [&quot;mycli help&quot;]
</code></pre>
<p>That way the pod does not restart and the cli inside is waiting for commands like <code>mycli do this</code></p>
<p>Is it a <code>hacky</code> way that is frowned upon or a legit solution?</p>

Kostas Demiris
<p>Your edit is one solution, another one if you do not want or cannot change the Docker image is to <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="nofollow noreferrer">Define a Command for a Container</a> to loop infinitely, this would achieve the same as the Dockerfile ENTRYPOINT but without having to rebuild the image.</p>
<p>Here's an example of such implementation:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: [&quot;/bin/sh&quot;, &quot;-ec&quot;, &quot;while :; do echo '.'; sleep 5 ; done&quot;]
  restartPolicy: OnFailure
</code></pre>
<p>As for your question about if this is a legit solution, this is hard to answer; I would say it depends on what your application is designed to do. Kubernetes Pods are designed to be ephemeral, so a good solution would be one that is running until the job is completed; for a web server, for example, the job is never completed because it should be constantly listening to requests.</p>
