gpt4 book ai didi

docker - 在 Helm chart values.yaml 中拉取 docker hub 镜像

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

我是 helm 和 Kubernetes 世界的新手。我正在使用 Docker、Kubernetes 和 helm 开发一个项目,我试图在 Kubernetes 上使用 helm chart 部署一个简单的 Nodejs 应用程序。

这是我尝试过的:

来自 Dockerfile:

FROM node:6.9.2
EXPOSE 30000
COPY server.js .
CMD node server.js

我已经构建了镜像,标记它并将它推送到 docker hub 存储库:MY_USERNAME/myhello:0.2

然后我运行简单的命令来创建一个 helm 图表:helm 创建我的图表它创建了一个包含所有 helm 组件的 mychart 目录。

然后我将 values.yaml 文件编辑为:

replicaCount: 1
image:
repository: MY_USERNAME/myhello
tag: 0.2
pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: ""

service:
type: NodePort
port: 80
externalPort: 30000

ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
paths: []
hosts:
- chart-example.local
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

之后我将图表安装为:helm install --name myhelmdep01 mychart

当运行 kubectl get pods它显示了 ErrImagePull

我尝试将图像名称命名为:docker.io/arycloud/myhello在这种情况下,图像已成功提取,但出现另一个错误:

Liveness probe failed: Get http://172.17.0.5:80/: dial tcp 172.17.0.5:80: connect: connection refused

最佳答案

运行 kubectl describe pod <yourpod>错误发生后不久,输出底部附近应该有一个事件告诉您图像拉取问题的确切原因。

在我的脑海中,它可能是以下选项之一:

  • 这是一个私有(private)仓库,您还没有为 pod/部署提供具有正确 imagePullSecret 的服务帐户
  • 您的后端不是 docker 或不假定非前缀图像在 hub.docker.com 上。试试这个:registry-1.docker.io/arycloud/myhello

如果您能找到该错误,那应该非常简单。

关于docker - 在 Helm chart values.yaml 中拉取 docker hub 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54292123/

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