Kubernetes从不安全的Docker注册表中提取

时间:2018-08-17 10:12:03

标签: docker kubernetes docker-registry

我在这个阶段已经堆砌了

  1. 具有本地docker不安全注册表以及其中的某些映像,例如192.168.1.161:5000/kafka:latest
  2. 具有kubernetes云集群,我只能通过〜/ .kube / config文件访问该集群,例如令牌。

需要在部署以下进行部署,但是kubernetes无法提取映像,错误消息:

  

无法提取图像“ 192.168.1.161:5000/kafka:latest”:RPC错误:   代码=未知desc =来自守护程序的错误响应:获取   https://192.168.1.161:5000/v2/:http:服务器对以下内容进行了HTTP响应:   HTTPS客户端

apiVersion: v1
kind: Service
metadata:
  name: kafka
  labels:
    app: kafka
spec:
  type: NodePort
  ports:
  - name: port9094
    port: 9094
    targetPort: 9094
  selector:
    app: kafka
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kafka
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: kafka
    spec:
      hostname: kafka
      containers:
      - name: redis
        image: 192.168.1.161:5000/kafka:latest
        imagePullPolicy: Always

      ports:
      - name: port9094
        containerPort: 9094
      - envFrom:
        - configMapRef:
            name: env

  imagePullSecrets:
  - name: regsec

在Kubernetes集群上,我使用以下命令创建了秘密文件“ regsec”:

kubectl create secret docker-registry regsec  --docker-server=192.168.1.161 --docker-username=<name from config file> --docker-password=<token value from config file>

cat ~/.docker/config.json
{
        "auths": {},
        "HttpHeaders": {
                "User-Agent": "Docker-Client/18.06.0-ce (linux)"
        }

cat /etc/docker/daemon.json
{
      "insecure-registries":["192.168.1.161:5000"]
}

kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}


    docker version
Client:
 Version:           18.06.0-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        0ffa825
 Built:             Wed Jul 18 19:09:54 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.0-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       0ffa825
  Built:            Wed Jul 18 19:07:56 2018
  OS/Arch:          linux/amd64
  Experimental:     false

1 个答案:

答案 0 :(得分:2)

您需要转到每个节点,编辑文件/etc/default/docker.json并在其中添加以下内容:

{
    “insecure-registries”: ["192.168.1.161:5000"]
}