本文介绍了Kubernetes imagePullSecrets不工作;获得“图像未找到”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在AWS上运行的现成的Kubernetes集群,并安装了 kube-up 脚本。我想运行一些私有Docker Hub存储库中的容器。但是我仍然收到一个未找到错误:

 > kubectl get pod 
NAME READY状态RESTARTS AGE
maestro-kubetest-d37hr 0/1错误:image csats / maestro:最新未找到0 22m

我创建了一个包含 .dockercfg 文件的秘密。我已经通过运行脚本发布了,证实了这一点: p>

 > kubectl get secrets docker-hub-csatsinternal -o yaml | grep dockercfg:| cut -f 2 -d:|碱基64 -D> 〜/ .dockercfg 
> docker pull csats / maestro
最新:从csats / maestro拉出

我确认了'不使用的新格式,我的看起来像这样: p>

 > cat〜/ .dockercfg 
{https://index.docker.io/v1/\":{\"auth\":\"REDACTED BASE64 STRING HERE,email:[email protected]}}

我尝试过

这是我的复制控制器的YAML:

  --- 
kind:ReplicationController
apiVersion:v1
元数据:
名称:maestro-kubetest
规格:
副本:1
选择器:
应用程序:maestro
生态系统:kubetest
版本:1
模板:
元数据:
标签:
应用程序:maestro
生态系统:kubetest
版本:1
规格:
imagePullSecrets :
- 名称:docker-hub-csatsinternal
容器:
- 名称:maestro
图像:csats / maestro
imagePullPolicy:

restartPolicy:Always
dnsPolicy:ClusterFirst

kubectl版本

 客户端版本:version.Info {Major :1,次要:0,GitVersion:v1.0.3,GitCommit: 61C6ac5f350253a4dc002aee97b7db7ff01ee4ca,GitTreeState:clean} 
服务器版本:version.Info {Major:1,Minor:0,GitVersion:v1.0.3,GitCommit:61c6ac5f350253a4dc002aee97b7db7ff01ee4ca,GitTreeState:clean }

任何想法?

Docker在〜/ .docker / $ b中生成一个 config.json $ b它看起来像:

  {
auths:{
index.docker.io / v1 /:{
auth:ZmFrZXBhc3N3b3JkMTIK,
email:[email protected]
}
}
}

您实际想要的是:

  {https://index.docker.io/v1/:{auth:XXXXXXXXXXXXXX,email:[email protected]}} 

注意事项:




  • 1)没有 auths wrap

  • 2)有 https:// 前面的
    URL

  • 3)一行



然后你 base64 编码并用作 .dockercfg 名称的数据

  apiVersion:v1 
kind:Secret
元数据:
名称:注册表
数据:
.dockercfg:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ==
类型:kubernetes。 io / dockercfg

再次注意 .dockercfg 一行(base64往往生成多行字符串)


I have an off-the-shelf Kubernetes cluster running on AWS, installed with the kube-up script. I would like to run some containers that are in a private Docker Hub repository. But I keep getting a "not found" error:

 > kubectl get pod
NAME                      READY     STATUS                                        RESTARTS   AGE
maestro-kubetest-d37hr    0/1       Error: image csats/maestro:latest not found   0          22m

I've created a secret containing a .dockercfg file. I've confirmed it works by running the script posted here:

 > kubectl get secrets docker-hub-csatsinternal -o yaml | grep dockercfg: | cut -f 2 -d : | base64 -D > ~/.dockercfg
 > docker pull csats/maestro
latest: Pulling from csats/maestro

I've confirmed I'm not using the new format of .dockercfg script, mine looks like this:

> cat ~/.dockercfg
{"https://index.docker.io/v1/":{"auth":"REDACTED BASE64 STRING HERE","email":"[email protected]"}}

I've tried running the Base64 encode on Debian instead of OS X, no luck there. (It produces the same string, as might be expected.)

Here's the YAML for my Replication Controller:

---
kind: "ReplicationController"
apiVersion: "v1"
metadata:
  name: "maestro-kubetest"
spec:
  replicas: 1
  selector:
    app: "maestro"
    ecosystem: "kubetest"
    version: "1"
  template:
    metadata:
      labels:
        app: "maestro"
        ecosystem: "kubetest"
        version: "1"
    spec:
      imagePullSecrets:
        - name: "docker-hub-csatsinternal"
      containers:
        - name: "maestro"
          image: "csats/maestro"
          imagePullPolicy: "Always"

      restartPolicy: "Always"
      dnsPolicy: "ClusterFirst"

kubectl version:

Client Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.3", GitCommit:"61c6ac5f350253a4dc002aee97b7db7ff01ee4ca", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"0", GitVersion:"v1.0.3", GitCommit:"61c6ac5f350253a4dc002aee97b7db7ff01ee4ca", GitTreeState:"clean"}

Any ideas?

解决方案

Docker generates a config.json file in ~/.docker/It looks like:

{
    "auths": {
        "index.docker.io/v1/": {
            "auth": "ZmFrZXBhc3N3b3JkMTIK",
            "email": "[email protected]"
        }
    }
}

what you actually want is:

{"https://index.docker.io/v1/": {"auth": "XXXXXXXXXXXXXX", "email": "[email protected]"}}

note 3 things:

  • 1) there is no auths wrapping
  • 2) there is https:// in front of theURL
  • 3) it's one line

then you base64 encode that and use as data for the .dockercfg name

apiVersion: v1
kind: Secret
metadata:
  name: registry
data:
  .dockercfg: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==
type: kubernetes.io/dockercfg

Note again the .dockercfg line is one line (base64 tends to generate a multi-line string)

这篇关于Kubernetes imagePullSecrets不工作;获得“图像未找到”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 22:52