0

Trying to insert output from this:

kubectl get pods | grep -Eo '^[^ ]+' | grep portal

Into this:

kubectl exec -it <here> portal bash

Tried:

kubectl exec -it `kubectl get pods | grep -Eo '^[^ ]+' | grep portal ` portal bash

But no luck.

2
  • 3
    What does "no luck" mean? Did you get some kind of error? Does the command in the command substitution return the correct thing? What happens if you use ... -it "$(...)" ... instead of the backticks (quoting is difficult with backticks). Commented Jun 13, 2019 at 16:18
  • @Kusalananda It says: Defaulting container name to portal-container. Use 'kubectl describe pod/portal-74767c88b-92sct' to see all of the containers in this pod. rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"portal\": executable file not found in $PATH" In both cases Commented Jun 13, 2019 at 16:37

1 Answer 1

1
kubectl exec -it "$(kubectl get pods | grep -Eo '^[^ ]+' | grep portal)" bash

Or, even more:

kubectl exec -c portal-container -it "$(kubectl get pods | grep -Eo '^[^ ]+' | grep portal)" bash

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.