Skip to content

Commit 8932551

Browse files
authored
feat(helm): support imagePullSecrets and make all images overridable (#70)
Add a global imagePullSecrets value that applies to every pod spec in the chart and propagates to controller-managed agent pods via env var. Also extract the hardcoded alpine:3.21 in the Keycloak provision job into keycloak.provisionImage for consistency. Signed-off-by: Tomas Pilar <thomas7pilar@gmail.com>
1 parent 7c30537 commit 8932551

11 files changed

Lines changed: 63 additions & 3 deletions

File tree

deploy/helm/humr/templates/_helpers.tpl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ Chart label
4545
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
4646
{{- end }}
4747

48+
{{/*
49+
imagePullSecrets — renders the imagePullSecrets list if non-empty.
50+
*/}}
51+
{{- define "humr.imagePullSecrets" -}}
52+
{{- with .Values.imagePullSecrets }}
53+
imagePullSecrets:
54+
{{- toYaml . | nindent 2 }}
55+
{{- end }}
56+
{{- end }}
57+
58+
{{/*
59+
nameList — comma-separated .name values from a list of objects.
60+
Usage: {{ include "humr.nameList" .Values.someList }}
61+
*/}}
62+
{{- define "humr.nameList" -}}
63+
{{- $names := list }}
64+
{{- range . }}
65+
{{- $names = append $names .name }}
66+
{{- end }}
67+
{{- join "," $names }}
68+
{{- end }}
69+
4870
{{/* ---- Public URLs (derived from domain + port + scheme) ---- */}}
4971

5072
{{/*

deploy/helm/humr/templates/apiserver/app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ spec:
3939
{{- include "humr.labels" . | nindent 8 }}
4040
app.kubernetes.io/component: apiserver
4141
spec:
42+
{{- include "humr.imagePullSecrets" . | nindent 6 }}
4243
serviceAccountName: {{ include "humr.apiserver.serviceAccountName" . }}
4344
containers:
4445
- name: apiserver

deploy/helm/humr/templates/controller/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ spec:
2121
{{- include "humr.selectorLabels" . | nindent 8 }}
2222
app.kubernetes.io/component: controller
2323
spec:
24+
{{- include "humr.imagePullSecrets" . | nindent 6 }}
2425
serviceAccountName: {{ include "humr.controller.serviceAccountName" . }}
2526
containers:
2627
- name: controller
@@ -58,6 +59,10 @@ spec:
5859
value: {{ .Values.controller.caCertInitImage | default "busybox:stable" }}
5960
- name: AGENT_IMAGE_PULL_POLICY
6061
value: {{ .Values.controller.agentImagePullPolicy | default "IfNotPresent" }}
62+
{{- with .Values.controller.agentImagePullSecrets }}
63+
- name: AGENT_IMAGE_PULL_SECRETS
64+
value: {{ include "humr.nameList" . }}
65+
{{- end }}
6166
- name: HUMR_IDLE_TIMEOUT
6267
value: {{ .Values.controller.idleTimeout | default "1h" | quote }}
6368
- name: HUMR_TERMINATION_GRACE_PERIOD

deploy/helm/humr/templates/keycloak/app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ spec:
4343
app.kubernetes.io/component: keycloak
4444
annotations: {}
4545
spec:
46+
{{- include "humr.imagePullSecrets" . | nindent 6 }}
4647
initContainers:
4748
- name: wait-for-postgres
4849
image: {{ .Values.postgres.image }}

deploy/helm/humr/templates/keycloak/provision-job.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ spec:
1919
{{- include "humr.labels" . | nindent 8 }}
2020
app.kubernetes.io/component: keycloak-provision
2121
spec:
22+
{{- include "humr.imagePullSecrets" . | nindent 6 }}
2223
restartPolicy: OnFailure
2324
initContainers:
2425
- name: config-cli
@@ -64,7 +65,7 @@ spec:
6465
keycloak-config-cli cannot modify realm-management authorizationSettings
6566
reliably, so we use the Admin REST API after realm import. */}}
6667
- name: token-exchange-setup
67-
image: alpine:3.21
68+
image: {{ .Values.keycloak.provisionImage }}
6869
env:
6970
- name: KC_URL
7071
value: "http://{{ $appName }}:{{ .Values.keycloak.port }}"

deploy/helm/humr/templates/onecli/app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ spec:
6363
{{- include "humr.labels" . | nindent 8 }}
6464
app.kubernetes.io/component: onecli
6565
spec:
66+
{{- include "humr.imagePullSecrets" . | nindent 6 }}
6667
initContainers:
6768
- name: wait-for-postgres
6869
image: {{ .Values.postgres.image }}

deploy/helm/humr/templates/postgres.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ spec:
6262
app.kubernetes.io/component: postgres
6363
app.kubernetes.io/instance: {{ .Release.Name }}
6464
spec:
65+
{{- include "humr.imagePullSecrets" . | nindent 6 }}
6566
containers:
6667
- name: postgres
6768
image: {{ .Values.postgres.image }}

deploy/helm/humr/templates/ui/app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ spec:
8484
annotations:
8585
checksum/nginx-config: {{ toYaml .Values.ui | sha256sum }}
8686
spec:
87+
{{- include "humr.imagePullSecrets" . | nindent 6 }}
8788
containers:
8889
- name: ui
8990
image: "{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag | default .Chart.AppVersion }}"

deploy/helm/humr/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ port: "4444"
66
# -- URL scheme (http for local dev, https for production)
77
scheme: http
88

9+
# -- Pull secrets for all pods managed by this chart.
10+
# Agent pods (managed by the controller) also inherit these secrets.
11+
# Example:
12+
# imagePullSecrets:
13+
# - name: my-registry-secret
14+
imagePullSecrets: []
15+
916
# -- Target namespace for agent workloads (instances, templates, schedules)
1017
agentNamespace: humr-agents
1118

@@ -107,6 +114,7 @@ keycloak:
107114
enabled: true
108115
image: quay.io/keycloak/keycloak:26.5.4
109116
configCliImage: adorsys/keycloak-config-cli:latest-26.5.4
117+
provisionImage: alpine:3.21
110118
port: 8080
111119

112120
# -- Admin credentials (for Keycloak admin console)
@@ -205,6 +213,9 @@ controller:
205213
pullPolicy: IfNotPresent
206214
caCertInitImage: busybox:stable
207215
agentImagePullPolicy: IfNotPresent
216+
# -- Pull secrets for agent pods (in agentNamespace, separate from chart-level imagePullSecrets).
217+
# The referenced secrets must exist in agentNamespace.
218+
agentImagePullSecrets: []
208219
replicas: 1
209220
# -- Idle timeout before auto-hibernating running instances (Go duration, 0 = disabled)
210221
idleTimeout: "1h"

packages/controller/pkg/config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"strconv"
7+
"strings"
78
"time"
89
)
910

@@ -22,6 +23,7 @@ type Config struct {
2223
LeaseName string // Leader election lease name
2324
PodName string // This pod's name (from downward API)
2425
AgentImagePullPolicy string // ImagePullPolicy for agent pods (default: IfNotPresent)
26+
AgentImagePullSecrets []string // Pull secret names for agent pods (comma-separated via env)
2527
IdleTimeout time.Duration // Idle timeout before auto-hibernation (0 = disabled, default: 1h)
2628
TerminationGracePeriod int64 // Termination grace period in seconds for agent pods (default: 5)
2729
CACertInitImage string // Image for the CA cert init container (default: busybox:stable)
@@ -55,6 +57,13 @@ func LoadFromEnv() (*Config, error) {
5557
}
5658
cfg.CACertInitImage = envOrDefault("CA_CERT_INIT_IMAGE", "busybox:stable")
5759
cfg.AgentImagePullPolicy = envOrDefault("AGENT_IMAGE_PULL_POLICY", "IfNotPresent")
60+
if v := os.Getenv("AGENT_IMAGE_PULL_SECRETS"); v != "" {
61+
for _, s := range strings.Split(v, ",") {
62+
if name := strings.TrimSpace(s); name != "" {
63+
cfg.AgentImagePullSecrets = append(cfg.AgentImagePullSecrets, name)
64+
}
65+
}
66+
}
5867
cfg.IdleTimeout = envOrDefaultDuration("HUMR_IDLE_TIMEOUT", 1*time.Hour)
5968
cfg.TerminationGracePeriod = int64(envOrDefaultInt("HUMR_TERMINATION_GRACE_PERIOD", 5))
6069
return cfg, nil

0 commit comments

Comments
 (0)