kubelet无法连接到本地Docker注册表

时间:2018-08-23 14:12:09

标签: docker kubernetes ubuntu-16.04

我按照本教程创建了一个本地docker注册表:https://www.serverlab.ca/tutorials/containers/docker/how-to-create-a-private-docker-registry-on-ubuntu/ 我可以拉出并推送图像没有问题,但是当我使用kubectl基于这些图像创建部署时,我得到了ImagePullBackOff

我确实更改了/etc/docker/daemon.json

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

docker version 1.13.1 我正在运行具有2个ubuntu VM的集群并使用kubeadm kubectl version 1.10.4

PS:我也尝试用IP地址主机更改localhost也不起作用。

# 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

这是用于推送图像的脚本

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 

0 个答案:

没有答案