kubectl set image throws error: the server doesn't have a resource type deployment"

4/1/2019

Environment: Win 10 home, gcloud sdk v240.0 kubectl added as a gcloud sdk component, Jenkins 2.169 I am running a Jenkins pipeline in which I call a windows batch file as a post-build action. In that batch file, I am running:

kubectl set image deployment/py-gmicro py-gmicro=%IMAGE_NAME%

I get this

error: the server doesn't have a resource type deployment

However, if I run the batch file directly from the command prompt, it works fine. Looks like it has an issue only if I run it from Jenkins.

Looked at a similar thread on stackoverflow, however that user was using bitbucket (instead of Jenkins).

Also, there was no certified answer on that thread. I cannot continue on that thread since I am not allowed to comment (50 reputation required)

-- Nagen
google-kubernetes-engine
jenkins
kubernetes

1 Answer

4/11/2019

Just was answered on this thread

I've had this error fixed by explicitly setting the namespace as an argument, e.g.:

kubectl set image -n foonamespace deployment/ms-userservice.....

Refrence: https://www.mankier.com/1/kubectl-set-image#--namespace

-- Raul Bautista
Source: StackOverflow