I am able to login to the container running in a pod using kubectl exec -t ${POD } /bin/bash --all-namespaces
(POD is the text parameter value in my Jenkins job, In which user would have entered the pod name before running the job), Now my question is : I am able to login into the container , I want to my test.sh file from the logged in container ? Flow:
Step1 : Run a Jenkins job which should login to a docker container running inside the pods
Step: From the container execute the test.sh script.
test.sh
echo "This is demo file"
There is no need to have two steps one step is sufficient. I believe below should get the job done
kubectl exec ${POD} /path/to/script/test.sh --all-namespaces
Below is the reference form Kubernetes documentation
kubectl exec my-pod -- ls / # Run command in existing pod (1 container case)
kubectl exec my-pod -c my-container -- ls / # Run command in existing pod (multi-container case)