I have a pod running in kubernetes and i need to run two commands in one line.
Say,
kubectl exec -it <pod name> -n <namespace > -- bash -c redis-cli
above command will open redis-cli
i want to run one more command after exec in one line ie info, i am trying below which is not working:
kubectl exec -it <pod name> -n <namespace > -- bash -c redis-cli -- info
3
Answers
Not get your question, do you want to get the information from redis-cli?
Did you try to link your commands using && ?
kubernetes exec -it <pod name> -n <namespace > -- bash -c redis-cli && info
You have to put your command and all the parameters between apostrophes.
in your example it would be:
Other option (which in my opinion is a better approach) is to get the output from the command with an instant pod, which creates, runs and deletes the pod right after that, like this:
in my case the password was stored in a envvar called $REDIS_PASSWORD and I’m connecting to a server in a pod called redis-master.
I let it as I runned it to show that you can use as much parameters as needed.
POC: