I was passed the following, which does a dry run of the creation of a kubernetes secret from an appsettings.json
file, which is then piped to a kubernetes apply
. I think that the -f
will take the filename of the --dry-run
created secret and use that when applying the secret, but I'm wondering if the trailing -
has any significance or if it's just a typo?
kubectl create secret generic test --from-file=appsettings.json --dry-run -oyaml | kubectl apply -f -
The
-
is a parameter to the-f
option, which means to accept input from standard input instead of a named file. Hundreds of UNIX/Linux commands have options like this.The
-
character can be understood as a placeholder for the output of the command which is piped ( using|
character ). By using it, we instruct very specifically the subsequent command ( to which the output is piped ), where the standard output of the first command ( it's execution result ) should be placed, in other words how it should be taken or parsed.So rather than piping the result of:
(which happens to be a yaml manifest)
directly to:
kubectl apply -f
which doesn't know what to do with such input (as it expects a file after
-f
flag), we indicate very precisely where it fits:In this case, we instruct
kubectl apply
command that the piped output from the previous command should be taken instead of a file, which is expected after providing-f
flag.