How to setup kubectl within jenkins How to setup kubectl within jenkins jenkins jenkins

How to setup kubectl within jenkins


You need to install kubectl on EC2 instance(follow this link: https://kubernetes.io/docs/tasks/tools/install-kubectl/).

Once it is installed you have to export the path:https://opensource.com/article/17/6/set-path-linux

or you use full path like : sh "~/place/where/kubectl/installed/kubectl apply -f platform_api_deployment.yml"


Are you running jenkins slave on the different Machine / EC2 ? I think you need to install the kubectl on the slave if it's different with your master node


You need to add the kubectl binary in dockerfile while building image in order to execute during jenkins job.

COPY kubectl /bin/kubectl 

Add this value in your docker file, once you get the kubectl binaries.