Search code examples
kubectl

How can we run a command with arguments on a pod using kubectl?


For example something like this should work but gives some errors. It seems like arguments need to be single no argument calls?

kubectl exec --stdin --tty pod 'cat myfile.txt'

Solution

  • Seems like it's is missing the -- before the command. From these docs for reference:

    kubectl exec pod  --stdin --tty -- cat myfile.txt
    

    But the usage for kubectl does show you can have have a command like that:

     kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]