I am starting with a simple test. The same way I successfully run:
docker run -t amigahub/casa:v1.0 --help
I am expecting the following command to behave similarly:
microk8s.kubectl run -i -t casa --image=amigahub/casa:v1.0 – --help
It seems to do the trick but then the pod enters in the “CrashLoopBackOff” status and I am not able to execute any commands inside the container again.
It looks like the way I built the container for Docker is not appropriate for Kubernetes. Do containers need to stick to certain requirements to be deployed with kubernetes?
The big difference is the docker command will execute it once and terminate. The default kind of object created in Kubernetes when you use a run command is a Deployment which will restart the container once it has exited. You’d want to create it as a job to execute once and terminate. You can do this with kubectl run by specifying the --restart=Never
$ kubectl run casa -i -t --image=amigahub/casa:v1.0 --restart=Never -- --help
If you don't see a command prompt, try pressing enter.
usage: casa [-h] [--rcdir RCDIR] [--logfile LOGFILE] [--maclogger]
[--log2term] [--nologger] [--nologfile] [--nogui]
[--colors {NoColor,Linux,LightBG}] [--trace] [--pipeline] [--agg]
[--iplog] [--nocrashreport] [-c ...]
Start CASA (Common Astronomy Software Applications)
optional arguments:
-h, --help show this help message and exit
--rcdir RCDIR location for startup files
--logfile LOGFILE path to log file
--maclogger logger to use on Apple systems
--log2term direct output to terminal
--nologger do not start CASA logger
--nologfile do not create a log file
--nogui avoid starting GUI tools
--colors {NoColor,Linux,LightBG}
prompt color
--trace list imported modules
--pipeline start CASA pipeline run
--agg startup without tkagg
--iplog create ipython log
--nocrashreport do not submit an online report when CASA crashes
-c ... python eval string or python script to execute
Many thanks @mrbobbytables for clarifying the basic concepts.
My question then is, what if I want to run the same container more than once with kubernetes?
When I type: kubectl run casa -i -t --image=amigahub/casa:v1.0 --restart=Never -- --help more than once, I get: Error from server (AlreadyExists): pods "casa" already exists
A job is being created under the hood by the run command when --restart=Never. If they’re rapidly working on a container, probably just passing the --rm=true flag is the easiest bet. Once ready to actually run it, definitely.