Docker kubectl得到豆荚

Docker kubectl得到豆荚,docker,kubernetes,minikube,Docker,Kubernetes,Minikube,我在和库伯内特斯战斗。我在谷歌上搜索了很多,并查看了一些答案,例如,但似乎无法让它发挥作用 我已创建docker容器并推送到本地注册表: sudo docker run -d -p 5000:5000 --name registry registry:2 sudo docker tag i-a/i-a:latest localhost:5000/i-a sudo docker push localhost:5000/i-a 最后一个命令给出: The push refers to a repo

我在和库伯内特斯战斗。我在谷歌上搜索了很多,并查看了一些答案,例如,但似乎无法让它发挥作用

我已创建docker容器并推送到本地注册表:

sudo docker run -d -p 5000:5000 --name registry registry:2
sudo docker tag i-a/i-a:latest localhost:5000/i-a
sudo docker push localhost:5000/i-a
最后一个命令给出:

The push refers to a repository [localhost:5000/i-a]
e0a33c56cca0: Pushed 
54ab83ede54d: Pushed 
f5a58f369605: Pushed 
cd7100a72410: Pushed 
latest: digest: sha256:0f30cdf6b4a4e0e382a6cae50c1325103c3b987d9e51c42edea2244a82ae1331 size: 1164
执行sudo docker pull localhost:5000/i-a

Using default tag: latest
latest: Pulling from i-a
Digest: sha256:0f30cdf6b4a4e0e382a6cae50c1325103c3b987d9e51c42edea2244a82ae1331
Status: Image is up to date for localhost:5000/i-a:latest
配置文件i-a.yaml:

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    run: i-a
  name: i-a
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      run: i-a
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        run: i-a
    spec:
      containers:
      - image: localhost:5000/i-a
        imagePullPolicy: IfNotPresent
        name: i-a
        ports:
        - containerPort: 8090
      dnsPolicy: ClusterFirst
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    run: i-a
  name: i-a
  namespace: default
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8090
  selector:
    run: i-a
  sessionAffinity: None
  type: ClusterIP
当我
sudo kubectl得到pods时——所有名称空间
我得到:

...
default       i-a-3400848339-0x6c9   0/1       ImagePullBackOff   0          13m
default       i-a-3400848339-7ltp1   0/1       ImagePullBackOff   0          13m
default       i-a-3400848339-wv092   0/1       ImagePullBackOff   0          13m
ImagePullBackOff
变为
ErrImagePull

当我运行
kubectl description pod I-a-3400848339-0x6c9
时,我得到一个错误
未能拉取映像“localhost:5000/I-a”:拉取映像时出错:gethttp://localhost:5000/v1/repositories/i-a/images:拨打tcp 127.0.0.1:5000:getsockopt:连接被拒绝

Name:       i-a-3400848339-0x6c9
Namespace:  default
Node:       minikube/192.168.99.100
Start Time: Mon, 09 Apr 2018 21:11:15 +0200
Labels:     pod-template-hash=3400848339
        run=i-a
Status:     Pending
IP:     172.17.0.7
Controllers:    ReplicaSet/i-a-3400848339
Containers:
  i-a:
    Container ID:                  
    Image:      localhost:5000/i-a
    Image ID:       
    Port:       8090/TCP
    State:      Waiting
      Reason:       ImagePullBackOff
    Ready:      False
    Restart Count:  0
    Volume Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-bmwkd (ro)
    Environment Variables:  <none>
Conditions:
  Type      Status
  Initialized   True 
  Ready     False 
  PodScheduled  True 
Volumes:
  default-token-bmwkd:
    Type:   Secret (a volume populated by a Secret)
    SecretName: default-token-bmwkd
QoS Class:  BestEffort
Tolerations:    <none>
Events:
  FirstSeen LastSeen    Count   From            SubobjectPath               Type        Reason      Message
  --------- --------    -----   ----            -------------               --------    ------      -------
  18m       18m     1   {default-scheduler }                        Normal      Scheduled   Successfully assigned i-a-3400848339-0x6c9 to minikube
  18m       2m      8   {kubelet minikube}  spec.containers{i-a}    Normal      Pulling     pulling image "localhost:5000/i-a"
  18m       2m      8   {kubelet minikube}  spec.containers{i-a}    Warning     Failed      Failed to pull image "localhost:5000/i-a": Error while pulling image: Get http://localhost:5000/v1/repositories/i-a/images: dial tcp 127.0.0.1:5000: getsockopt: connection refused
  18m       2m      8   {kubelet minikube}                      Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "i-a" with ErrImagePull: "Error while pulling image: Get http://localhost:5000/v1/repositories/i-a/images: dial tcp 127.0.0.1:5000: getsockopt: connection refused"

  18m   13s 75  {kubelet minikube}  spec.containers{i-a}    Normal  BackOff     Back-off pulling image "localhost:5000/i-a"
  18m   13s 75  {kubelet minikube}                      Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "i-a" with ImagePullBackOff: "Back-off pulling image \"localhost:5000/i-a\""
名称:i-a-3400848339-0x6c9
名称空间:默认值
节点:minikube/192.168.99.100
开始时间:2018年4月9日星期一21:11:15+0200
标签:pod模板哈希=3400848339
运行=i-a
状态:待定
IP:172.17.0.7
控制器:ReplicaSet/i-a-3400848339
容器:
i-a:
容器ID:
图片:localhost:5000/i-a
图像ID:
端口:8090/TCP
国家:等待
原因:图像拉回
就绪:错误
重新启动计数:0
卷装载:
/默认令牌bmwkd(ro)中的var/run/secrets/kubernetes.io/serviceCount
环境变量:
条件:
类型状态
初始化为True
准备错误
播客预定为真
卷数:
默认令牌bmwkd:
类型:Secret(由Secret填充的卷)
SecretName:默认令牌bmwkd
QoS等级:最佳努力
容忍:
活动:
子对象路径类型原因消息中的FirstSeen LastSeen计数
--------- --------    -----   ----            -------------               --------    ------      -------
18m 18m 1{default scheduler}正常调度已成功将i-a-3400848339-0x6c9分配给minikube
18m 2m 8{kubelet minikube}规格容器{i-a}正常拉取图像“localhost:5000/i-a”
18m 2m 8{kubelet minikube}spec.containers{i-a}警告未能拉取映像“localhost:5000/i-a”:拉取映像时出错:Gethttp://localhost:5000/v1/repositories/i-a/images:拨打tcp 127.0.0.1:5000:getsockopt:连接被拒绝
18m 2m 8{kubelet minikube}警告同步pod失败同步错误,跳过:无法使用ErrImagePull为“i-a”启动“StartContainer”:“拉图像时出错:获取”http://localhost:5000/v1/repositories/i-a/images:拨打tcp 127.0.0.1:5000:getsockopt:连接被拒绝”
18m 13s 75{kubelet minikube}规范容器{i-a}正常回退回退拉取图像“localhost:5000/i-a”
18m 13s 75{kubelet minikube}警告同步pod失败,跳过:无法使用图像回拉“回拉图像”本地主机:5000/i-a“为“i-a”启动容器”
我不知道下一步该去哪里看。。。 (当我浏览到时得到404)

尝试:

spec:
      containers:
      - image: localhost:5000/i-a
        imagePullPolicy: Never
        name: i-a
        ports:
        - containerPort: 8090
      dnsPolicy: ClusterFirst
      restartPolicy: Always
从Spec/containers下的映像中删除“localhost:5000/”,并将ImagePullPolicy设置为Never。它应该允许您从本地注册表中提取此图像。当然,此映像将仅对托管docker私有注册表的节点可用。