简体   繁体   English

kubernetes:容器未开始使用私有注册表

[英]kubernetes : Containers not starting using private registry

I have a working installation with kubernetes 1.1.1 running on debian我有一个在 debian 上运行的 kubernetes 1.1.1 的工作安装

I also have a private registry working nice running in v2 ..我还有一个在 v2 中运行良好的私有注册表..

I am facing a weird problem.我正面临一个奇怪的问题。

defining a pod in master在 master 中定义一个 pod

apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: docker-registry.hiberus.com:5000/debian:ssh
imagePullSecrets:
- name: myregistrykey

I also have the secret on my master myregistrykey kubernetes.io/dockercfg 1 44m我的主myregistrykey kubernetes.io/dockercfg 1 44m上也有秘密myregistrykey kubernetes.io/dockercfg 1 44m

and my config.json is made this way我的 config.json 就是这样制作的

{
"auths": {
"https://docker-registry.hiberus.com:5000": {
"auth": "anNhdXJhOmpzYXVyYQ==",
"email": "jsaura@heraldo.es"
}
}
}

and so I did the base64 and created my secret.所以我做了 base64 并创建了我的秘密。

simple as hell简单到地狱

on my node the image gets pulled without any problem在我的节点上,图像被拉出没有任何问题

docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker-registry.hiberus.com:5000/debian ssh 3b332951c107 29 minutes ago 183.3 MB
golang 1.4 2819d1d84442 7 days ago 562.7 MB
debian latest 91bac885982d 8 days ago 125.1 MB
gcr.io/google_containers/pause 0.8.0 2c40b0526b63 7 months ago 241.7 kB

but my container does not start但我的容器没有启动

./kubectl describe pod nginx
Name: nginx
Namespace: default
Image(s): docker-registry.hiberus.com:5000/debian:ssh
Node: 192.168.29.122/192.168.29.122
Start Time: Wed, 18 Nov 2015 17:08:53 +0100
Labels: app=nginx
Status: Running
Reason:
Message:
IP: 172.17.0.2
Replication Controllers: 
Containers:
nginx:
Container ID: docker://3e55ab118a3e5d01d3c58361abb1b23483d41be06741ce747d4c20f5abfeb15f
Image: docker-registry.hiberus.com:5000/debian:ssh
Image ID: docker://3b332951c1070ba2d7a3bb439787a8169fe503ed8984bcefd0d6c273d22d4370
State: Waiting
Reason: CrashLoopBackOff
Last Termination State: Terminated
Reason: Error
Exit Code: 0
Started: Wed, 18 Nov 2015 17:08:59 +0100
Finished: Wed, 18 Nov 2015 17:08:59 +0100
Ready: False
Restart Count: 2
Environment Variables:
Conditions:
Type Status
Ready False
Volumes:
default-token-ha0i4:
Type: Secret (a secret that should populate this volume)
SecretName: default-token-ha0i4
Events:
FirstSeen LastSeen Count From SubobjectPath Reason Message
───────── ──────── ───── ──── ───────────── ────── ───────
16s 16s 1 {kubelet 192.168.29.122} implicitly required container POD Created Created with docker id 4a063be27162
16s 16s 1 {kubelet 192.168.29.122} implicitly required container POD Pulled Container image "gcr.io/google_containers/pause:0.8.0" already present on machine
16s 16s 1 {kubelet 192.168.29.122} implicitly required container POD Started Started with docker id 4a063be27162
16s 16s 1 {kubelet 192.168.29.122} spec.containers{nginx} Pulling Pulling image "docker-registry.hiberus.com:5000/debian:ssh"
15s 15s 1 {scheduler } Scheduled Successfully assigned nginx to 192.168.29.122
11s 11s 1 {kubelet 192.168.29.122} spec.containers{nginx} Created Created with docker id 36df2dc8b999
11s 11s 1 {kubelet 192.168.29.122} spec.containers{nginx} Pulled Successfully pulled image "docker-registry.hiberus.com:5000/debian:ssh"
11s 11s 1 {kubelet 192.168.29.122} spec.containers{nginx} Started Started with docker id 36df2dc8b999
10s 10s 1 {kubelet 192.168.29.122} spec.containers{nginx} Pulled Container image "docker-registry.hiberus.com:5000/debian:ssh" already present on machine
10s 10s 1 {kubelet 192.168.29.122} spec.containers{nginx} Created Created with docker id 3e55ab118a3e
10s 10s 1 {kubelet 192.168.29.122} spec.containers{nginx} Started Started with docker id 3e55ab118a3e
5s 5s 1 {kubelet 192.168.29.122} spec.containers{nginx} Backoff Back-off restarting failed docker container

it loops internally trying to start but it never does它在内部循环尝试启动,但从未启动

the weird thing is that if y do a run command on my node manually the container starts without any problem, but using the pod pulls the image but never starts ..奇怪的是,如果你在我的节点上手动执行运行命令,容器启动没有任何问题,但使用 pod 拉图像但从未启动..

am I doing something wrong?难道我做错了什么?

if I use a public image for my pod it starts without any problem .. this only happens to me when using private images ..如果我为我的 pod 使用公共图像,它启动时没有任何问题..这只会在使用私有图像时发生在我身上..

I have also moved from debian to ubuntu, no luck same problem我也从 debian 转移到 ubuntu,没有运气同样的问题

I have also linked the secret to de default service account, still no luck我还将秘密链接到默认服务帐户,仍然没有运气

cloned last git version, compiled, no luck ..克隆了最后一个 git 版本,编译,没有运气..

It is clear for me that the problem is using private registry, but I have applied and followed all info I have read and still no luck.对我来说很明显问题是使用私有注册表,但我已经申请并遵循了我阅读的所有信息,但仍然没有运气。

A docker container could exit if it's main process has exit.如果 docker 容器的主进程已退出,则它可能会退出。 Could you share container logs ?你能分享容器日志吗?

  1. if you do docker ps -a you should see all running and exited containers如果你执行docker ps -a你应该看到所有正在运行和退出的容器
  2. Run docker container logs container_id运行docker container logs container_id

Also try running your container in interactive and daemon mode and see if it fails only in daemon mode.还尝试以交互和守护程序模式运行您的容器,看看它是否仅在守护程序模式下失败。

Running in daemon mode -在守护进程模式下运行 -

docker run -d -t Image_name

Running in interactive mode -以交互模式运行 -

docker run -it Image_name

for interactive daemon mode docker run -idt Image_name对于交互式守护进程模式docker run -idt Image_name

refer - Why docker container exits immediately参考 - 为什么 docker 容器会立即退出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM