I'm interested to know tried and tested techniques for running CLI applications against a Kubernetes cluster.
Our services take the form of docker images. It seems logical that our CLI applications should also be docker images. This gives us a bunch of options to run CLI applications against services inside our Kubernetes cluster.
Ultimately we can run the images locally (docker run
) run them inside the cluster (kubectl run
) or have a "noop" container we run commands in (kubectl exec
). The main downside of running outside is we don't get context (like DNS). But running inside seems like it might be slow: slow start up as image is pulled on to a node and the latency involved in running an interactive terminal over HTTP. The "noop" container feels a bit hacky.
Does anyone have any other approaches to this problem?
There is Jobs for this:
A job creates one or more pods and ensures that a specified number of them successfully terminate. As pods successfully complete, the job tracks the successful completions. When a specified number of successful completions is reached, the job itself is complete. Deleting a Job will cleanup the pods it created.