fix: use image pull secrets instead of registries.yaml to reference private repositories

While this will now more or less require a local docker login - which can be overridden by setting the image-pull-secrets property - this ensures every deploy has a valid context.

One annoying thing is that the secret is per-app vs global, meaning that if the secret must be rotated, all apps need to be redeployed. A future change can fix that by deploying a global secret, or if folks really desire, this can be done by setting the image-pull-secrets property on the app/globally.
This commit is contained in:
Jose Diaz-Gonzalez
2024-02-12 17:15:37 -05:00
parent 91151cf375
commit 1ae2df52f5
14 changed files with 49 additions and 206 deletions

View File

@@ -111,7 +111,8 @@ spec:
workingDir: {{ $.Values.global.image.working_dir }}
{{- end }}
{{- if $.Values.global.image.image_pull_secrets }}
imagePullSecrets: {{ $.Values.global.image.image_pull_secrets }}
imagePullSecrets:
- name: {{ $.Values.global.image.image_pull_secrets }}
{{- end }}
restartPolicy: Never
serviceAccountName: {{ $.Values.global.app_name }}

View File

@@ -125,6 +125,7 @@ spec:
workingDir: {{ $.Values.global.image.working_dir }}
{{- end }}
{{- if $.Values.global.image.image_pull_secrets }}
imagePullSecrets: {{ $.Values.global.image.image_pull_secrets }}
imagePullSecrets:
- name: {{ $.Values.global.image.image_pull_secrets }}
{{- end }}
serviceAccountName: {{ $.Values.global.app_name }}

View File

@@ -0,0 +1,23 @@
{{- if $.Values.global.image.pull_secret_base64 }}
---
apiVersion: v1
kind: Secret
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
dokku.com/managed: "true"
{{- if and $.Values.global.annotations $.Values.global.annotations.secret }}
{{- range $k, $v := $.Values.global.annotations.secret }}
{{ $k }}: {{ $v | quote }}
{{- end }}
{{- end }}
labels:
app.kubernetes.io/instance: image-pull-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
app.kubernetes.io/name: image-pull-{{ $.Values.global.app_name }}
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
name: image-pull-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
namespace: {{ $.Values.global.namespace }}
data:
.dockerconfigjson: "{{ $.Values.global.image.pull_secret_base64 }}"
type: kubernetes.io/dockerconfigjson
{{- end }}

View File

@@ -1,3 +1,4 @@
---
apiVersion: v1
kind: Secret
metadata: