How do I authenticate GKE to my third-party private docker registry?

12/27/2017

I'd like to deploy pods into my GKE Kubernetes cluster that use images from a private, third-party Docker registry (not GCP's private Docker registry).

How do I provide my GKE Kubernetes cluster with credentials to that private repository so that the images can be pulled when required?

-- Matthew Adams
docker-registry
gcp
google-cloud-platform
google-kubernetes-engine
kubernetes

1 Answer

12/28/2017

You need to create a secret that holds the credentials needed to download images from the private registry. This process is explained on Kubernetes documentation, but it looks like

kubectl create secret docker-registry regsecret --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>

Then, once your secret has been created, you need to specify that you want to use this secret to pull images from the registry when creating the pod's containers with the imagePullSecrets key containing the name of the secret created above, like

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: <your-private-image>
  imagePullSecrets:
  - name: regsecret
-- Jose Armesto
Source: StackOverflow