kubectl command running in VM but not running in jenkins pipeline

10/27/2021

I have installed jenkins on the ubuntu server. I have copied the config file to my home .kube/config folder. When I am running "kubectl get pods" command directly in the VM, it's running fine. But when I ran it in the jenkins pipeline the command is failing. I have tried it with providing --kubeconfig $PATHFORKUBECONFIG file.

Can anyone please help me with my query?

-- KJ1791
devops
jenkins
kubernetes

1 Answer

10/30/2021

You have installed jenkins as a different user with custom PATH environment. Access to the cluster uses the amazon iam-helper binary, which is not on the PATH for the jenkins user.

Either add the location of the binary to your PATH (of jenkins user) or put the binary to a location which is on the path, for example /usr/local/bin

-- Thomas
Source: StackOverflow