gpt4 book ai didi

docker - 无法通过 Kubernetes 从 GitHub 拉取公共(public) docker 镜像包

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

我创建了一个 sample Node.js project在 GitHub 中并为此创建了一个 docker 镜像。我将 docker 镜像作为一个包上传到同一个存储库中。这是一个公共(public) repo 。我创建了一个 kubernetes 配置 yaml 文件,将此图像用作 pod 图像。以下是yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
name: server-deployment
spec:
selector:
matchLabels:
component: node-server
template:
metadata:
labels:
component: node-server
spec:
containers:
- name: node-server
image: docker.pkg.github.com/lethalbrains/intense_omega/io_service:latest
ports:
- containerPort: 3000
imagePullSecrets:
- name: dockerconfigjson-github-com
---
apiVersion: v1
kind: Service
metadata:
name: server-cluster-ip-service
spec:
selector:
component: node-server
ports:
- port: 3000
targetPort: 3000
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
kubernetes.io/inress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /api/
backend:
serviceName: server-cluster-ip-service
servicePort: 3000

使用 Kubectl 应用此文件并检查 pod 详细信息后,我收到 ImagePullBackOff 错误。

enter image description here

我什至试过 using this option使用带有 Github 个人访问 token 的 dockerconfigjson secret ,但仍然是 sam 结果。

编辑:

添加了来自 pod 描述的错误消息
enter image description here

最佳答案

这似乎是 GitHub 注册表的问题,正在讨论 here .

我可以推荐的是把图片推送到docker hub或者,如果创建您可以在 Using a private Docker Registry with Kubernetes 上阅读的私有(private)仓库.

似乎有一种解决方法,但我没有测试过。
@sudomaxime 发布并且可用 here :

Here's a nasty little workaround for thoses who:

  • Don't mind loosing blue/green deploys until this is resolved
  • Don't mind 10-15 secs app start-up time
  • Use docker swarm / docker stack deploys
  • Use CI scripts for deployment

In your CI scripts call:

$ docker stack rm {{ your_stack_name }}
$ until [ -z $(docker stack ps {{ your_stack_name }} -q) ]; do sleep 1; done
$ docker stack deploy --with-registry-auth -c docker-compose.yml {{ your_stack_name }}

Basically you ask Docker scheduler to stop all the services under {{ your_stack_name }} orchestrator. A little knack of docker swarm is that docker stack rm will immediately return even if some services are not properly closed chich may cause networking errors when you try to deploy again. That's why we use a small inline script until [ -z $(docker stack ps {{ your_stack_name }} -q) ]; do sleep 1; done to wait for the proper return.

Hopes it saves a few folks headaches. I guess a similar temporary fix will help you out.

This is quite a frustrating issue, for our apps that MUST use blue/green deploys we bought a private repo to fix the problem.

关于docker - 无法通过 Kubernetes 从 GitHub 拉取公共(public) docker 镜像包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62076276/

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