Reputation: 21
Team, I need to execute a shell script that is within a kubernetes pod. However the call needs to come from outside the pod. Below is the script for your reference:
echo 'Enter Namespace: '; read namespace; echo $namespace;
kubectl exec -it `kubectl get po -n $namespace|grep -i podName|awk '{print $1}'` -n $namespace --- {scriptWhichNeedToExecute.sh}
Can anyone suggest on how to do this?`
Upvotes: 0
Views: 756
Reputation: 54247
There isn't really a good way. A simple option might be cat script.sh | kubectl exec -i -- bash
but that can have weird side effects. The more correct solution would be to use a debug container but that feature is still in alpha right now.
Upvotes: 1