<p>Trying to run a local registry. I have the following configuration:</p>

<p>Deployment:</p>

<pre><code>apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: registry
  labels:
    app: registry
    role: registry
spec:
  replicas: 1
  selector:
    matchLabels:
      app: registry
  template:
    metadata:
      labels:
        app: registry
    spec:
      containers:
      - name: registry
        image: registry:latest
        ports:
        - containerPort: 5000
        volumeMounts:
          - mountPath: '/registry'
            name: registry-volume
      volumes:
      - name: registry-volume
        hostPath:
          path: '/data'
          type: Directory
</code></pre>

<p>Service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: registry
  namespace: default
  labels:
    app: registry
spec:
  selector:
    role: registry
  type: NodePort
  ports:
    - name: registry
      nodePort: 31001
      port: 5000
      protocol: TCP
</code></pre>

<p>It all works well when I create deployment/service. <code>kubectl</code> shows status as <code>Running</code> for both service and deployment:</p>

<pre><code>NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/registry   1         1         1            1           30m

NAME                     DESIRED   CURRENT   READY     AGE
rs/registry-6549cbc974   1         1         1         30m

NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/registry   1         1         1            1           30m

NAME                     DESIRED   CURRENT   READY     AGE
rs/registry-6549cbc974   1         1         1         30m

NAME                           READY     STATUS    RESTARTS   AGE
po/registry-6549cbc974-mmqpj   1/1       Running   0          30m

NAME             TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
svc/kubernetes   ClusterIP   10.0.0.1     &lt;none&gt;        443/TCP          37m
svc/registry     NodePort    10.0.0.6     &lt;none&gt;        5000:31001/TCP   7m
</code></pre>

<p>However, when I try to get external IP for service using: <code>minikube service registry --url</code>, it times-out/fails: <code>Waiting, endpoint for service is not ready yet...</code>.</p>

<p>When I delete the service (keeping deployment intact), and manually expose the deployment using <code>kubectl expose deployment registry --type=NodePort</code>, I am able to get it working.</p>

<p>Minikube log can be found <a href="https://pastebin.com/KHEPGwaZ" rel="nofollow noreferrer">here</a>.</p>

<p>You need to specify the correct <code>spec.selector</code> in <code>registry</code> service manifest:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: registry
  namespace: default
  labels:
    app: registry
spec:
  selector:
    app: registry
  type: NodePort
  ports:
    - name: registry
      nodePort: 31001
      port: 5000
      protocol: TCP
</code></pre>

<p>Now <code>registry</code> service correctly points to the <code>registry</code> pod:</p>

<pre><code>$ kubectl get endpoints
NAME         ENDPOINTS         AGE
kubernetes   10.0.2.15:8443    14m
registry     172.17.0.4:5000   4s
</code></pre>

<p>And you can get external url as well:</p>

<pre><code>$ minikube service registry --url
http://192.168.99.106:31001
</code></pre>
