Kubernetes: kubectl 无法从私有仓库中拉取镜像

创建于 2017-02-16  ·  3评论  ·  资料来源: kubernetes/kubernetes

这是错误报告还是功能请求?:错误

Kubernetes 版本(使用 kubectl 版本):

Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-01-12T04:57:25Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:34:56Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}

环境:

云供应商或硬件配置: 2GB RAM/50GB HDD VM
操作系统(例如来自 /etc/os-release):
名称=“Ubuntu”
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL=" http://www.ubuntu.com/ "
SUPPORT_URL=" http://help.ubuntu.com/ "
BUG_REPORT_URL=" http://bugs.launchpad.net/ubuntu/ "
UBUNTU_CODENAME=xenial

内核(例如 uname -a):
Linux ubuntu 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
安装工具: kubeadm、kubectl、docker
其他:NA
发生了什么: ImagePullBackOff 从私有存储库中拉取时

你期望发生的事情:它从私有存储库中提取图像

如何重现它(尽可能最小和精确):

  • 为私有存储库创建一个文件并在节点(主从)中重新启动docker
    root<strong i="5">@ubuntu</strong>:~# vi /etc/systemd/system/docker.service.d/private-registry.conf
        [Service]
        ExecStart=
        ExecStart=/usr/bin/dockerd --insecure-registry 123.456.789.0:9595
  • 然后,Docker登录
    docker login 123.456.789.0:9595
  • 码头工人信息
    集装箱:87
    跑步:18
    暂停:0
    停止:69
    图片:175
    服务器版本:1.12.3
    存储驱动:aufs
    根目录:/var/lib/docker/aufs
    后备文件系统:extfs
    目录:384
    支持 Dirperm1:true
    日志驱动:json-file
    Cgroup 驱动程序:cgroupfs
    插件:
    体积:本地
    网络:主机桥空覆盖
    群:不活动
    运行时:runc
    默认运行时:runc
    安全选项:apparmor seccomp
    内核版本:4.4.0-21-generic
    操作系统:Ubuntu 16.04 LTS
    操作系统类型:linux
    架构:x86_64
    CPU:1
    总内存:1.937 GiB
    名称: ubuntu
    ID:FXD7: JQJZ:HO3R :D2NK: RWYL:7DCY :PC2M:43PM:MA7C: QSPN:4RGS :5W6H
    Docker 根目录:/var/lib/docker
    调试模式(客户端):false
    调试模式(服务器):false
    注册表: https :
    警告:不支持交换限制
    不安全的注册表:
    123.456.789.0:9595
    127.0.0.0/8

  • 码头工人 -v
    Docker 版本 1.12.3,构建 6b644ec

  • 在 master 中启动 kubeadm
    kubeadm init --token 123456.1234567890123456 --api-advertise-addresses 192.168.91.133

  • 创建 kubernate 秘密
    kubectl 创建秘密 docker-registry my-secret --docker-server=123.456.789.0 --docker-username=admin --docker-password=XXXX [email protected]
  • 创建了 weive 网络

    kubectl apply -f https://git.io/weave-kube

  • 从slave,加入master网络
    kubeadm join --token=123456.1234567890123456 192.168.91.133
  • Pod 定义
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  labels:
    name: test
spec:
  containers:
    - image: 123.456.789.0:9595/test
      name: test
      ports:
        - containerPort: 8443
  imagePullSecrets:
    - name: my-secret
  • 然后,尝试创建一个 pod。 配置的 pod 映像位于 nexus docker 存储库中。我在描述 pod 时得到以下跟踪
Name:           test-pod
Namespace:      default
Node:           ubuntu-child/192.168.91.134
Start Time:     Thu, 16 Feb 2017 12:26:56 +0530
Labels:         name=test
Status:         Pending
IP:             10.44.0.2
Controllers:    <none>
Containers:
  test:
    Container ID:
    Image:              123.456.789.0:9595/test
    Image ID:
    Port:               8443/TCP
    State:              Waiting
      Reason:           ErrImagePull
    Ready:              False
    Restart Count:      0
    Volume Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-vkj94 (ro)
    Environment Variables:      <none>
Conditions:
  Type          Status
  Initialized   True
  Ready         False
  PodScheduled  True
Volumes:
  default-token-vkj94:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-vkj94
QoS Class:      BestEffort
Tolerations:    <none>
Events:
  FirstSeen     LastSeen        Count   From                    SubObjectPath                   Type            Reason          Message
  ---------     --------        -----   ----                    -------------                   --------        ------          -------
  9s            9s              1       {default-scheduler }                                    Normal          Scheduled       Successfully assigned test-pod to ubuntu-child
  7s            7s              1       {kubelet ubuntu-child}  spec.containers{test}   Normal          Pulling         pulling image "123.456.789.0:9595/test"
  7s            7s              1       {kubelet ubuntu-child}  spec.containers{test}   Warning         Failed          Failed to pull image "123.456.789.0:9595/test": Error: image test:latest not found
  7s            7s              1       {kubelet ubuntu-child}                                  Warning         FailedSync      Error syncing pod, skipping: failed to "StartContainer" for "test" with ErrImagePull: "Error: image test:latest not found"

  7s    7s      1       {kubelet ubuntu-child}  spec.containers{test}   Normal  BackOff         Back-off pulling image "123.456.789.0:9595/test"
  7s    7s      1       {kubelet ubuntu-child}                                  Warning FailedSync      Error syncing pod, skipping: failed to "StartContainer" for "test" with ImagePullBackOff: "Back-off pulling image \"123.456.789.0:9595/test\""

最有用的评论

由于端口号存在问题。 输入端口号后,它已按预期开始工作。

kubectl create secret docker-registry my-secret --docker-server=123.456.789.0:9595 --docker-username=admin --docker-password=XXXX [email protected]

所有3条评论

从奴隶和主人,我可以拉私人存储库。 但是,尽管我在 pod 定义中添加了我的秘密,但当 kubectl 尝试从私有存储库中提取图像时,问题就存在了。

由于端口号存在问题。 输入端口号后,它已按预期开始工作。

kubectl create secret docker-registry my-secret --docker-server=123.456.789.0:9595 --docker-username=admin --docker-password=XXXX [email protected]

此页面是否有帮助?
0 / 5 - 0 等级