Kubernetes download image from GCR private repo

1/10/2020

I'm trying to launch kube deployment with image stored on Google Cloud Platform, I can download it manually with docker docker pull gcr.io/<project>/toolkit-image the privileges are there, a simple deployment says

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  47s                default-scheduler  Successfully assigned default/testimage-jenkins-5bdc57567f-ss5qh to minikube
  Normal   BackOff    17s (x3 over 45s)  kubelet, minikube  Back-off pulling image "gcr.io/toolkit-image:latest"
  Warning  Failed     17s (x3 over 45s)  kubelet, minikube  Error: ImagePullBackOff
  Normal   Pulling    6s (x3 over 46s)   kubelet, minikube  Pulling image "gcr.io/toolkit-image:latest"
  Warning  Failed     6s (x3 over 45s)   kubelet, minikube  Failed to pull image "gcr.io/toolkit-image:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://gcr.io/v2/toolkit-image/manifests/latest: unknown: Project 'project:toolkit-image' not found or deleted.
  Warning  Failed     6s (x3 over 45s)   kubelet, minikube  Error: ErrImagePull

and my values

master:
  adminPassword: <testr_pass>
  resources:
    limits:
      cpu: 500m
      memory: 1Gi
  podLabels:
    nodePort: 32323
  serviceType: ClusterIP
  image: "gcr.io/<project>/toolkit-image"
  tag: "latest"

rbac:
  create: true

Same happens if I try to pull with or without \project\ val inside gcr.io/project/toolkit-image

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  53s                default-scheduler  Successfully assigned default/testimage-jenkins-f5856f9c9-65prx to minikube
  Normal   BackOff    22s (x2 over 49s)  kubelet, minikube  Back-off pulling image "gcr.io/<project>/toolkit-image:latest"
  Warning  Failed     22s (x2 over 49s)  kubelet, minikube  Error: ImagePullBackOff
  Normal   Pulling    7s (x3 over 52s)   kubelet, minikube  Pulling image "gcr.io/<project>/toolkit-image:latest"
  Warning  Failed     5s (x3 over 49s)   kubelet, minikube  Failed to pull image "gcr.io/<project>/toolkit-image:latest": 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
  Warning  Failed     5s (x3 over 49s)   kubelet, minikube  Error: ErrImagePull

Any ideas how to make kubectl see the private Google Cloud Platform Repository ?

PS: gcloud auth configure-docker this command to authenticate doesn't help at all

-- CptDolphin
containers
google-cloud-platform
kubernetes
kubernetes-helm
minikube

1 Answer

1/10/2020

If your private registry requires authentication, you need to configure imagePullSecrets.

See https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

-- Shashank V
Source: StackOverflow