你们好,希望您一切顺利!
我需要我的主计算机命令从服务器从我的docker hub存储库中提取映像,并且出现以下错误,它不允许从服务器从存储库中提取图像,但是当我手动访问从计算机时拉他拉
这来自kubernetes管理员:
第一行是对pod my-app-6c99bd7b9c-dqd6l的描述,该代码现在正在运行,因为我是从Docker集线器中手动提取映像的,但我希望Kubernetes可以做到。
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled <unknown> default-scheduler Successfully assigned default/my-app2-74969ddd4f-l6d6l to kubeslave.machine.pt
Normal SandboxChanged <invalid> kubelet, kubeslave.machine.pt Pod sandbox changed, it will be killed and re-created.
Warning Failed <invalid> (x3 over <invalid>) kubelet, kubeslave.machine.pt Failed to pull image "bedjase/repository/my-java-app:my-java-app": rpc error: code = Unknown desc = Error response from daemon: pull access denied for bedjase/repository/my-java-app, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Warning Failed <invalid> (x3 over <invalid>) kubelet, kubeslave.machine.pt Error: ErrImagePull
Normal BackOff <invalid> (x7 over <invalid>) kubelet, kubeslave.machine.pt Back-off pulling image "bedjase/repository/my-java-app:my-java-app"
Warning Failed <invalid> (x7 over <invalid>) kubelet, kubeslave.machine.pt Error: ImagePullBackOff
Normal Pulling <invalid> (x4 over <invalid>) kubelet, kubeslave.machine.pt Pulling image "bedjase/repository/my-java-app:my-java-app"
[root@kubernetes ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
my-app-6c99bd7b9c-dqd6l 1/1 Running 0 14m
my-app2-74969ddd4f-l6d6l 0/1 ImagePullBackOff 0 2m20s
nginx-86c57db685-bxkpl 1/1 Running 0 8h
这是来自奴隶的:
[root@kubeslave docker]# docker pull bedjase/repository:my-java-app
my-java-app: Pulling from bedjase/repository
50e431f79093: Already exists
dd8c6d374ea5: Already exists
c85513200d84: Already exists
55769680e827: Already exists
e27ce2095ec2: Already exists
5943eea6cb7c: Already exists
3ed8ceae72a6: Already exists
7ba151cdc926: Already exists
Digest: sha256:c765d09bdda42a4ab682b00f572fdfc4bbcec0b297e9f7716b3e3dbd756ba4f8
Status: Downloaded newer image for bedjase/repository:my-java-app
docker.io/bedjase/repository:my-java-app
我已经在docker hub repo的主服务器和从服务器中都进行了登录并成功。 都可以使用/ etc / hosts,也可以连接节点并准备就绪:
[root@kubernetes ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
kubernetes.machine.pt Ready master 26h v1.17.4
kubeslave.machine.pt Ready <none> 26h v1.17.4
我在这里想漏点吗?
答案 0 :(得分:0)
对于私有映像,必须使用Docker Hub的secret
和username
创建一个password
,Kubernetes才能拉取映像。
下面的命令使用您的Docker Hub凭据创建一个秘密名称regcred
,替换字段<<your-name>>
,<your-password>
和<your-email>
:
kubectl create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=<your-name> --docker-password=<your-password> --docker-email=<your-email>
之后,您需要在pod / deployment规范中添加要使用此凭据的拉动私有图像,并添加imagePullSecrets
和上面创建的凭据,请参见以下示例:
apiVersion: v1
kind: Pod
metadata:
name: private-reg
spec:
containers:
- name: private-reg-container
image: <your-private-image>
imagePullSecrets:
- name: regcred
参考:
答案 1 :(得分:0)
只需添加其他答案,
1)使用以下命令创建密钥: Create a secret for pulling docker images
2)按照以下说明创建使用此秘密的Pod: use the secret in pod