How to reference kubernetes docker-registry

3/30/2019

I have installed docker-registry on Kubernetes via helm.

I am able to docker push to docker push 0.0.0.0:5000/<my-container>:v1 using port-forward.

Now how do I reference the images in the registry from a deployment.yaml?

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: <my-container>-deployment-v1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: <my-container>-deployment
        version: v1
    spec:
      containers:
      - name: <my-container>
        image: 0.0.0.0:5000/<my-container>:v1 # <<< ????
        imagePullPolicy: Always
        ports:
        - containerPort: 80
      imagePullSecrets:
        - name: private-docker-registry-secret

This do list my containers:

curl -X GET http://0.0.0.0:5000/v2/_catalog

I keep getting ImagePullBackOff when deploying.

I tyied using internal service name and cluster ip address, still not working.

Then tried using secrets:

{
  "kind": "Secret",
  "apiVersion": "v1",
  "metadata": {
    "name": "running-buffoon-docker-registry-secret",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/secrets/running-buffoon-docker-registry-secret",
    "uid": "127c93c1-53df-11e9-8ede-a63ad724d5b9",
    "resourceVersion": "216488",
    "creationTimestamp": "2019-03-31T18:01:56Z",
    "labels": {
      "app": "docker-registry",
      "chart": "docker-registry-1.7.0",
      "heritage": "Tiller",
      "release": "running-buffoon"
    }
  },
  "data": {
    "haSharedSecret": "xxx"
  },
  "type": "Opaque"
}

And added the secret to to deployment.yaml:

  imagePullSecrets:
    - name: running-buffoon-docker-registry-secret

Then I get:

image "x.x.x.x/:<my-container>v1": rpc error: code = Unknown desc = Error response from daemon: Get https://x.x.x.x/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
-- Chris G.
cert-manager
kubernetes

1 Answer

3/31/2019

You need to get the cluster-ip of your local docker registry.

You will find this in the dashboard - just visit the registry pod page and then to the associated service. Replace your image spec's 0.0.0.0 with the cluster ip. Also make sure the port matches - generally the port exposed by registry service is different from the actual port exposed inside the cluster. If you have authentication set up in your registry, you will need imagepullsecret as well.

I have blogged about minikube setup with a local registry - might be helpful. https://amritbera.com/journal/minikube-insecure-registry.html

-- Amrit Bera
Source: StackOverflow