我的DigitalOcean kubernetes集群无法从DigitalOcean注册表中提取图像。我收到以下错误消息:
Failed to pull image "registry.digitalocean.com/XXXX/php:1.1.39": rpc error: code = Unknown desc = failed to pull and unpack image
"registry.digitalocean.com/XXXXXXX/php:1.1.39": failed to resolve reference
"registry.digitalocean.com/XXXXXXX/php:1.1.39": failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized我使用DigitalOcean容器注册表集成添加了kubernetes集群,它成功地显示在注册中心和kubernetes集群的设置上。

我可以确认上面的地址是‘Regiy.数字化海洋学网站/XXXX/php:1.1.39与注册表中的地址相匹配。我想知道我是否误解了令牌/登录集成如何与注册表一起工作,但我的印象是这是“一次单击”的事情,集群将在那之后自动获得到注册表的连接。
我已经尝试过在推送之前登录到注册表中,但这不起作用(而且我也不指望它会这样做,集群应该会拉出映像)。
对我来说还不完全清楚这张图像是如何被利用的。
我的舵机部署图基本上是API平台的默认配置图:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "api-platform.fullname" . }}
labels:
{{- include "api-platform.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "api-platform.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "api-platform.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "api-platform.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-caddy
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.caddy.image.repository }}:{{ .Values.caddy.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.caddy.image.pullPolicy }}
env:
- name: SERVER_NAME
value: :80
- name: PWA_UPSTREAM
value: {{ include "api-platform.fullname" . }}-pwa:3000
- name: MERCURE_PUBLISHER_JWT_KEY
valueFrom:
secretKeyRef:
name: {{ include "api-platform.fullname" . }}
key: mercure-publisher-jwt-key
- name: MERCURE_SUBSCRIBER_JWT_KEY
valueFrom:
secretKeyRef:
name: {{ include "api-platform.fullname" . }}
key: mercure-subscriber-jwt-key
ports:
- name: http
containerPort: 80
protocol: TCP
- name: admin
containerPort: 2019
protocol: TCP
volumeMounts:
- mountPath: /var/run/php
name: php-socket
#livenessProbe:
# httpGet:
# path: /
# port: admin
#readinessProbe:
# httpGet:
# path: /
# port: admin
resources:
{{- toYaml .Values.resources | nindent 12 }}
- name: {{ .Chart.Name }}-php
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.php.image.repository }}:{{ .Values.php.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.php.image.pullPolicy }}
env:
{{ include "api-platform.env" . | nindent 12 }}
volumeMounts:
- mountPath: /var/run/php
name: php-socket
readinessProbe:
exec:
command:
- docker-healthcheck
initialDelaySeconds: 120
periodSeconds: 3
livenessProbe:
exec:
command:
- docker-healthcheck
initialDelaySeconds: 120
periodSeconds: 3
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: php-socket
emptyDir: {}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}如何授权kubernetes集群从注册表中提取?这是舵手的事还是库伯奈特的事?
谢谢!
发布于 2022-10-25 20:52:48
问题是API平台在舵图中自动具有imagePullSecrets的默认值,即
imagePullSecrets: []
因此,这似乎以我预期的方式覆盖了kubernetes访问imagePullSecrets的权限。解决方案是将imagePullSecrets的名称直接添加到helm部署命令中,如下所示:
--set "imagePullSecrets[0].name=registry-secret-name-goes-here"
您可以使用以下kubectl get secrets查看您的秘密名称:
kubectl get secrets
输出应该如下所示:
NAME TYPE DATA AGE
default-token-lz2ck kubernetes.io/service-account-token 3 38d
registry-secret-name-goes-here kubernetes.io/dockerconfigjson 1 2d16h 发布于 2022-10-05 18:54:48
所存在的问题是,您没有一个图像提取秘密可供集群使用以从注册表中提取。
您需要添加这一点,以便为集群提供一种向集群授权其请求的方法。
在容器注册表中使用DigitalOcean kubernetes集成
数字海洋提供了一种向您帐户中的kubernetes集群添加图像提取秘密的方法。可以在注册表的设置中将注册表链接到群集。在"DigitalOcean Kuberentes“下选择编辑,然后选择要将注册表链接到的集群。

此操作向集群中的所有命名空间添加图像拉秘密,并将在默认情况下使用(除非另行指定)。
https://stackoverflow.com/questions/73964858
复制相似问题