If I run the command
$ kubectl exec pod-name echo Hello World
I get a deprecation error message asking me to include the '--' characters.
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Why was the decision made to require the '--' characters there? It seems unnecessary to me. I understand it's deprecated, I'm just trying to understand the reasoning behind the decision.
CodePudding user response:
According the book "Kubernetes in action" by Marko Luksa:
Why the double dash?
The double dash (--) in the command signals the end of command options for kubectl. Everything after the double dash is the command that should be executed inside the pod . Using the double dash isn’t necessary if the command has no arguments that start with a dash. But in your case, if you don’t use the double dash there, the -s option would be interpreted as an option for kubectl exec and would result in the following strange and highly misleading error: $ kubectl exec kubia-7nog1 curl -s http://10.111.249.153 The connection to the server 10.111.249.153 was refused – did you specify the right host or port? This has nothing to do with your service refusing the connection. It’s because kubectl is not able to connect to an API server at 10.111.249.153 (the -s option is used to tell kubectl to connect to a different API server than the default).