kubelet can't connect to local docker registry

8/23/2018

I created a local docker registry following this tutorial: https://www.serverlab.ca/tutorials/containers/docker/how-to-create-a-private-docker-registry-on-ubuntu/ i can pull and push images no problem but when I use kubectl to create deployments based on those images i get ImagePullBackOff.

i did change the /etc/docker/daemon.json

{ "insecure-registries":["localhost:5000"] } 

docker version 1.13.1 i am running a cluster with 2 ubuntu VMs and using kubeadm kubectl version 1.10.4

PS: i also tried to change localhost with the ip address master also didn't work.

# Copyright 2017 Istio Authors
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

##################################################################################################
# Details service
##################################################################################################
apiVersion: v1
kind: Service
metadata:
  name: details
  labels:
    app: details
spec:
  ports:
  - port: 9080
    name: http
  selector:
    app: details
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: details-v1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: details
        version: v1
    spec:
      containers:
      - name: details
        image: 192.168.1.109:5000/examples-bookinfo-details-v1:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
---
##################################################################################################
# Ratings service
##################################################################################################
apiVersion: v1
kind: Service
metadata:
  name: ratings
  labels:
    app: ratings
spec:
  ports:
  - port: 9080
    name: http
  selector:
    app: ratings
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ratings-v1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: ratings
        version: v1
    spec:
      containers:
      - name: ratings
        image: 192.168.1.109:5000/examples-bookinfo-ratings-v1:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
---
##################################################################################################
# Reviews service
##################################################################################################
apiVersion: v1
kind: Service
metadata:
  name: reviews
  labels:
    app: reviews
spec:
  ports:
  - port: 9080
    name: http
  selector:
    app: reviews
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: reviews-v1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: reviews
        version: v1
    spec:
      containers:
      - name: reviews
        image: 192.168.1.109:5000/examples-bookinfo-reviews-v1:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: reviews-v2
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: reviews
        version: v2
    spec:
      containers:
      - name: reviews
        image: 192.168.1.109:5000/examples-bookinfo-reviews-v2:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: reviews-v3
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: reviews
        version: v3
    spec:
      containers:
      - name: reviews
        image: 192.168.1.109:5000/examples-bookinfo-reviews-v3:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
---
##################################################################################################
# Productpage services
##################################################################################################
apiVersion: v1
kind: Service
metadata:
  name: productpage
  labels:
    app: productpage
spec:
  ports:
  - port: 9080
    name: http
  selector:
    app: productpage
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: productpage-v1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: productpage
        version: v1
    spec:
      containers:
      - name: productpage
        image: 192.168.1.109:5000/examples-bookinfo-productpage-v1:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9080
---



master@master:~$ kubectl describe pod/details-v1-6c767d44dc-j6hn6 -nbookinfo-v1
Name:           details-v1-6c767d44dc-j6hn6
Namespace:      bookinfo-v1
Node:           worker/192.168.1.110
Start Time:     Thu, 23 Aug 2018 15:20:20 +0200
Labels:         app=details
                pod-template-hash=2732380087
                version=v1
Annotations:    sidecar.istio.io/status={"version":"5a357b5fa6005e3d7642e92accb42383c4782e9865d5c5df193217a69bebcf46","initContainers":["istio-init"],"containers":["istio-proxy"],"volumes":["istio-envoy","istio-certs...
Status:         Pending
IP:             192.168.171.109
Controlled By:  ReplicaSet/details-v1-6c767d44dc
Init Containers:
  istio-init:
    Container ID:  docker://f95e6e2f4a3514028e1c12ab1435b03a7965ca6cfae032013f44ee3b2c80c93c
    Image:         gcr.io/istio-release/proxy_init:1.0.0
    Image ID:      docker-pullable://gcr.io/istio-release/proxy_init@sha256:345c40053b53b7cc70d12fb94379e5aa0befd979a99db80833cde671bd1f9fad
    Port:          <none>
    Host Port:     <none>
    Args:
      -p
      15001
      -u
      1337
      -m
      REDIRECT
      -i
      *
      -x

      -b
      9080,
      -d

    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Thu, 23 Aug 2018 15:20:27 +0200
      Finished:     Thu, 23 Aug 2018 15:20:29 +0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:         <none>
Containers:
  details:
    Container ID:   
    Image:          192.168.1.109:5000/examples-bookinfo-details-v1:latest
    Image ID:       
    Port:           9080/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-w8csb (ro)
  istio-proxy:
    Container ID:  docker://43407fd83342b6215e714090db5a676ddb4bc04fdccc1c5d382a1b96b28b4e05
    Image:         gcr.io/istio-release/proxyv2:1.0.0
    Image ID:      docker-pullable://gcr.io/istio-release/proxyv2@sha256:77915a0b8c88cce11f04caf88c9ee30300d5ba1fe13146ad5ece9abf8826204c
    Port:          <none>
    Host Port:     <none>
    Args:
      proxy
      sidecar
      --configPath
      /etc/istio/proxy
      --binaryPath
      /usr/local/bin/envoy
      --serviceCluster
      details
      --drainDuration
      45s
      --parentShutdownDuration
      1m0s
      --discoveryAddress
      istio-pilot.istio-system:15007
      --discoveryRefreshDelay
      1s
      --zipkinAddress
      zipkin.istio-system:9411
      --connectTimeout
      10s
      --statsdUdpAddress
      istio-statsd-prom-bridge.istio-system:9125
      --proxyAdminPort
      15000
      --controlPlaneAuthPolicy
      NONE
    State:          Running
      Started:      Thu, 23 Aug 2018 15:20:31 +0200
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:  10m
    Environment:
      POD_NAME:                      details-v1-6c767d44dc-j6hn6 (v1:metadata.name)
      POD_NAMESPACE:                 bookinfo-v1 (v1:metadata.namespace)
      INSTANCE_IP:                    (v1:status.podIP)
      ISTIO_META_POD_NAME:           details-v1-6c767d44dc-j6hn6 (v1:metadata.name)
      ISTIO_META_INTERCEPTION_MODE:  REDIRECT
    Mounts:
      /etc/certs/ from istio-certs (ro)
      /etc/istio/proxy from istio-envoy (rw)
Conditions:
  Type           Status
  Initialized    True 
  Ready          False 
  PodScheduled   True 
Volumes:
  default-token-w8csb:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-w8csb
    Optional:    false
  istio-envoy:
    Type:    EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:  Memory
  istio-certs:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  istio.default
    Optional:    true
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason   Age                 From             Message
  ----     ------   ----                ----             -------
  Normal   BackOff  50m (x148 over 1h)  kubelet, worker  Back-off pulling image "192.168.1.109:5000/examples-bookinfo-details-v1:latest"
  Warning  Failed   45s (x362 over 1h)  kubelet, worker  Error: ImagePullBackOff

and this is the script that ised to push the images

set -o errexit

if [ "$#" -ne 1 ]; then
    echo Missing version parameter
    echo Usage: build-services.sh \<version\>
    exit 1
fi

VERSION=$1

docker tag istio/examples-bookinfo-productpage-v1:${VERSION}  192.168.1.109:5000/examples-bookinfo-productpage-v1:latest 
  istio/examples-bookinfo-details-v1:${VERSION} 192.168.1.109:5000/examples-bookinfo-details-v1:latest \
  istio/examples-bookinfo-details-v2:${VERSION} 192.168.1.109:5000/examples-bookinfo-details-v2:latest \
  istio/examples-bookinfo-reviews-v1:${VERSION} 192.168.1.109:5000/examples-bookinfo-reviews-v1:latest \
  istio/examples-bookinfo-reviews-v2:${VERSION} 192.168.1.109:5000/examples-bookinfo-reviews-v2:latest \
  istio/examples-bookinfo-reviews-v3:${VERSION} 192.168.1.109:5000/examples-bookinfo-reviews-v3:latest \
  istio/examples-bookinfo-ratings-v1:${VERSION} 192.168.1.109:5000/examples-bookinfo-ratings-v1:latest \
  istio/examples-bookinfo-ratings-v2:${VERSION} 192.168.1.109:5000/examples-bookinfo-ratings-v2:latest \
  istio/examples-bookinfo-mysqldb:${VERSION} 192.168.1.109:5000/examples-bookinfo-mysqldb:latest \
  istio/examples-bookinfo-mongodb:${VERSION} 192.168.1.109:5000/examples-bookinfo-mongodb:latest 

docker push 192.168.1.109:5000/examples-bookinfo-productpage-v1:latest \
 192.168.1.109:5000/examples-bookinfo-details-v1:latest \
 192.168.1.109:5000/examples-bookinfo-details-v2:latest \
 192.168.1.109:5000/examples-bookinfo-reviews-v1:latest \
 192.168.1.109:5000/examples-bookinfo-reviews-v2:latest \
 192.168.1.109:5000/examples-bookinfo-reviews-v3:latest \
 192.168.1.109:5000/examples-bookinfo-ratings-v1:latest \
 192.168.1.109:5000/examples-bookinfo-ratings-v2:latest \
 192.168.1.109:5000/examples-bookinfo-mysqldb:latest \
 192.168.1.109:5000/examples-bookinfo-mongodb:latest 
-- mariam triki
docker
kubernetes
ubuntu-16.04

0 Answers