gpt4 book ai didi

docker - Kubernetes 无法从 docker hub 存储库中提取图像

转载 作者:行者123 更新时间:2023-12-02 12:28:51 25 4
gpt4 key购买 nike

大家好,希望你们一切都好!

我需要我的主机命令从机从我的 docker hub 存储库中提取图像,我得到下面的错误,它不会让从机从存储库中拉出,但是当我去从机时,手动拉他拉

这来自 Kubernetes 大师:

第一行是来自 pod my-app-6c99bd7b9c-dqd6l 的描述,它现在正在运行,因为我从 docker hub 手动提取了图像,但我希望 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 的 master 和 slave 中登录并成功了。
两者都有/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

我在这里错过了什么吗?

最佳答案

对于私有(private)图像,您必须创建一个 secretusernamepassword Docker Hub 到 Kubernetes 能够拉取镜像。

下面的命令创建一个 secret 名称regcred使用您的 Docker Hub 凭据,替换字段 <<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 规范中添加您想要使用此凭据来提取您的私有(private)镜像并添加 imagePullSecrets使用上面创建的凭据,请参阅此示例:
apiVersion: v1
kind: Pod
metadata:
name: private-reg
spec:
containers:
- name: private-reg-container
image: <your-private-image>
imagePullSecrets:
- name: regcred

引用文献:

https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-pod-that-uses-your-secret

关于docker - Kubernetes 无法从 docker hub 存储库中提取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60847252/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com