fix: update containerd config template to handle image registry authentication more robustly (#2842)

Signed-off-by: redscholar <blacktiledhouse@gmail.com>
This commit is contained in:
liujian 2025-11-07 17:10:22 +08:00 committed by GitHub
parent c75b70bbcd
commit 6e382eaa73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,20 +59,22 @@ state = "/run/containerd"
{{- if or (.cri.registry.auths | empty | not) (.groups.image_registry | default list | empty | not) }}
[plugins."io.containerd.grpc.v1.cri".registry.configs]
{{- end }}
{{- if .image_registry.auth.registry | empty | not }}
[plugins."io.containerd.grpc.v1.cri".registry.configs."{{ .image_registry.auth.registry }}".auth]
username = "{{ .image_registry.auth.username }}"
password = "{{ .image_registry.auth.password }}"
[plugins."io.containerd.grpc.v1.cri".registry.configs."{{ .image_registry.auth.registry }}".tls]
{{- if .image_registry.auth.ca_file | empty | not }}
{{- if .image_registry.auth.ca_file | empty | not }}
ca_file = "/etc/containerd/certs.d/{{ .image_registry.auth.registry }}/ca.crt"
{{- end }}
{{- if .image_registry.auth.cert_file | empty | not }}
{{- end }}
{{- if .image_registry.auth.cert_file | empty | not }}
cert_file = "/etc/containerd/certs.d/{{ .image_registry.auth.registry }}/server.crt"
{{- end }}
{{- if .image_registry.auth.key_file | empty | not }}
{{- end }}
{{- if .image_registry.auth.key_file | empty | not }}
key_file = "/etc/containerd/certs.d/{{ .image_registry.auth.registry }}/server.key"
{{- end }}
{{- end }}
insecure_skip_verify = {{ .image_registry.auth.insecure | default true }}
{{- end }}
{{- if .cri.registry.auths | empty | not }}
{{- range .cri.registry.auths }}
[plugins."io.containerd.grpc.v1.cri".registry.configs."{{ .repo }}".auth]