我正在尝试为kubernetes集群设置私有docker映像注册表。我正在使用link
$ cat ~/.docker/config.json | base64
ewoJImF1dGhzIjogewoJCSJsb2NhbGhvc3Q6NTAwMDAiOiB7CgkJCSJhdXRoIjogImJYbDFjMlZ5
T21oMGNHRnpjM2RrIgoJCX0KCX0KfQ==
我有文件image-registry-secrets.yaml
,内容如下-
apiVersion: v1
kind: Secret
metadata:
name: registrypullsecret
data:
.dockerconfigjson:ewoJImF1dGhzIjogewoJCSJsb2NhbGhvc3Q6NTAwMDAiOiB7CgkJCSJhdXRoIjogImJYbDFjMlZ5T21oMGNHRnpjM2RrIgoJCX0KCX0KfQ==
type: kubernetes.io/dockerconfigjson
当我运行下面的命令时
$kubectl create -f image-registry-secrets.yaml --validate=false && kubectl get secrets
Error from server (BadRequest): error when creating "image-registry-secrets.yml": Secret in version "v1" cannot be handled as a Secret: v1.Secret.Data: ReadMapCB: expect { or n, but found ", error found in #10 byte of ...|","data":".dockercon|..., bigger context ...|{"apiVersion":"v1","data":".dockerconfigjson:ewoJImF1dGhzIjogewoJCSJsb2NhbGhv|...
kubectl create -f image-registry-secrets.yaml --validate=false
中的问题是什么?如何解决此错误?
Kubernetes版本是-
$kubectl version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.0", GitCommit:"ddf47ac13c1a9483ea035a79cd7c10005ff21a6d", GitTreeState:"clean", BuildDate:"2018-12-03T21:04:45Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:30:26Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
2条答案
按热度按时间5n0oy7gb1#
您需要在
.dockerconfigjson
之后和base64字符串之前包含一个空格-在此之后,它应该可以工作。mm9b1k5b2#
粘贴base64密码时,会将密码拆分为几行,并在行与行之间添加空格,这很难解释,也不需要在
.dockerconfigjson
后面添加空格,因为教程中提供的yaml是正确的,粘贴base64-encoded-json
后出现问题。在Vim中打开秘密并运行:
:set listchars+=space:␣
和:set list
这将显示所有的空格为␣
,检查密码行之间是否没有空格。更新:Vim命令并不总是显示空格,所以只需导航到密钥的每一行,然后按退格键,使它们连接起来。