'kubectl not found' while running through ssh-task bamboo

11/20/2018

I have created a job in bamboo and created a ssh-task to run on my server. My server has already installed kubectl and below command executed successfully there.

 echo `kubectl get namespace`

But while running command through job, its showing below error:

 bash: line 5: kubectl: command not found
-- kohi
ansible
bamboo
kubernetes

1 Answer

11/20/2018

Please be sure that kubectl binary is in PATH of the user context, that your job is running in.

Otherwise you should use absolute path of kubectl executable, e.g. /usr/bin/kubectl)

  1. Indenity the location of kubectl executable: which kubectl
  2. Move it from its current location to location included in PATH, e.g. "sudo mv ./kubectl /usr/local/bin/kubectl"
-- Nepomucen
Source: StackOverflow