Problem with pulling docker images from gcr in kubernetes plugin / jenkins

8/6/2019

I have a gke cluster with a running jenkins master. I am trying to start a build. I am using a pipeline with a slave configured by the kubernetes plugin (pod Templates). I have a custom image for my jenkins slave published in gcr (private access). I have added credentials (google service account) for my gcr to jenkins. Nevertheless jenkins/kubernetes is failing to start-up a slave because the image can't be pulled from gcr. When I use public images (jnlp) there is no issue. But when I try to use the image from gcr, kubernetes says:

Failed to pull image "eu.gcr.io/<project-id>/<image name>:<tag>": rpc error: code = Unknown desc = Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication

Although the pod is running in the same project as the gcr.

I would expect jenkins to start the slave even if I use a image from gcr.

-- Stephan
docker
docker-registry
jenkins
kubernetes
pull

1 Answer

8/6/2019

Even if the pod is running in a cluster in the same project, is not authenticated by default.

Is stated that you've already set up the Service Account and I assume that there's a furnished key in the Jenkins server.

If you're using the Google OAuth Credentials Plugin you can then also use the Google Container Registry Auth Plugin to authenticate to a private GCR repository and pull the image.

-- yyyyahir
Source: StackOverflow