Recently when I am reading Kubernetes documentation, I met the command like below:
kubectl run curl --image=radial/busyboxplus:curl -i --tty
I know the kubectl run syntax is like the part before the colon, however I am not sure what is colon usage in the kubectl run, it is not mentioned in kubectl run syntax2, which is:
$ kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]And also I am not sure what is the usage of
curl -i --tty
from documentation, -i stands for "stdin", but why need --tty ?
I am not sure what is colon usage in the kubectl run
It's the docker container's "tag", which identifies which version of radial/busyboxplus you wish for kubernetes to run
from documentation, -i stands for "stdin", but why need --tty ?
That is only required if the process expects to interact with a virtual terminal; you are free to omit it, and only add it back in if the container emits an error. The same is true for the -i -- or actually, in this case, it is more likely that you can omit the -i than --tty unless you are expecting to read the curl payload from your local machine
+1 to mdaniel's answer however let me also add a few words to what was already said.
First of all I must say that you're grouping the expressions in quite a strange way 🙂 And it's not about kubectl command syntax but general convention applied to all Unix/Linux commands. Just take a look at it again:
kubectl run curl --image=radial/busyboxplus:curl -i --ttyThere are no spaces between : and preceding/proceeding part so your natural interpretation should be rather that the following fragment:
--image=radial/busyboxplus:curlis a separated/extracted part of the whole command. It's a flag --image belonging to kubectl run command specification with its value which happens to be radial/busyboxplus:curl. And this value cannot be part of kubectl specification as here you put simply the name of the docker image so your searching should go naturally to docker images naming convention rather looking for the meaning of : in context of kubectl command.
And this is nothing unusual. As mdaniel already stated in his answer, after : you specify docker image tag. Compare it with this example where nginx:1.14.2 is used. Using only nginx means nginx:latest as by default the latest tag is used but if we want a specific image version, we can provide it as tag, in this case 1.14.2 after the :.
In your example it's an image named radial/busyboxplus and tagged curl. In other words curl is the specific version of the radial/busyboxplus image.
As to:
curl -i --tty
such grouping of the expression is completely wrong. You posted it as if there was something like:
--image=radial/busyboxplus:"curl -i --tty"in your command. ❗ But there aren't any quotes there.
So coming back again to Unix command convention, you should never group parts of the expression this way. Let's take a look again at your command:
kubectl run curl --image=radial/busyboxplus:curl -i --ttyThere are meaningful spaces in between the individual parts of the command so both -i and --tty are flags of kubectl run command, the same as --image and are part of its specification.
To avoid any confusion you can re-arrange it a bit and it could look as well like this:
kubectl run curl -i --tty --image=radial/busyboxplus:curlTo check the meaning and usage of both flags you just need to run:
kubectl run --help(the meaning and justification for use of -i and --tty has already been well expalained by mdaniel.)