Skip to content

Commit f9a7e7a

Browse files
authored
Merge pull request #141 from BergCyrill/feature/no-ref/add-image-pullsecrets
Add the ability to provide imagePullSecrets for private Registries or Registries with auth
2 parents 122eb09 + d690e9e commit f9a7e7a

21 files changed

+147
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22

33
# output of hack/ci/validate-helm-resources.sh
44
*-templated.yaml
5+
6+
# remove local development nix configs
7+
*.nix
8+
*.lock
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
{{- define "name" -}}{{ .Release.Name }}{{- end }}
22
{{- define "agentname" -}}{{ .Values.agentName | default .Release.Name }}{{- end }}
3+
4+
{{- define "imagePullSecrets" -}}
5+
{{- range .Values.global.imagePullSecrets }}
6+
{{- if eq (typeOf .) "map[string]interface {}" }}
7+
- {{ toYaml . | trim }}
8+
{{- else }}
9+
- name: {{ . }}
10+
{{- end }}
11+
{{- end }}
12+
{{- end -}}

charts/api-syncagent/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ spec:
2424
app.kubernetes.io/instance: '{{ template "agentname" . }}'
2525
app.kubernetes.io/version: '{{ .Values.image.tag | default .Chart.AppVersion }}'
2626
spec:
27+
{{- if .Values.global.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- include "imagePullSecrets" . | trim | nindent 8 }}
30+
{{- end }}
2731
containers:
2832
- name: agent
2933
args:

charts/api-syncagent/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
global:
2+
## Reference to one or more secrets to be used when pulling images
3+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
4+
##
5+
imagePullSecrets: []
6+
# - name: "image-pull-secret"
7+
# or
8+
# - "image-pull-secret"
19
# Required: the name of the APIExport in kcp that this Sync Agent is supposed to serve.
210
apiExportName: ""
311

charts/cache/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
{{- end -}}
2020
{{- end -}}
2121

22+
{{- define "kcp.imagePullSecrets" -}}
23+
{{- range .Values.global.imagePullSecrets }}
24+
{{- if eq (typeOf .) "map[string]interface {}" }}
25+
- {{ toYaml . | trim }}
26+
{{- else }}
27+
- name: {{ . }}
28+
{{- end }}
29+
{{- end }}
30+
{{- end -}}
31+
2232
{{- define "certificates.kcp" -}}
2333
{{- if not (eq .Values.certificates.name "") -}}
2434
{{- $trimmedName := printf "%s" .Values.certificates.name | trunc 58 | trimSuffix "-" -}}

charts/cache/templates/cache-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ spec:
4747
hostAliases:
4848
{{- toYaml .Values.cache.hostAliases.values | nindent 6 }}
4949
{{- end }}
50+
{{- if .Values.global.imagePullSecrets }}
51+
imagePullSecrets:
52+
{{- include "kcp.imagePullSecrets" . | trim | nindent 8 }}
53+
{{- end }}
5054
containers:
5155
- name: cache
5256
image: {{ .Values.cache.image }}:{{- include "cache.version" . }}

charts/cache/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
global:
2+
## Reference to one or more secrets to be used when pulling images
3+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
4+
##
5+
imagePullSecrets: []
6+
# - name: "image-pull-secret"
7+
# or
8+
# - "image-pull-secret"
19
externalHostname: ""
210
cache:
311
enabled: true

charts/kcp-operator/templates/_helpers.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ Expand the name of the chart.
55
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
66
{{- end }}
77

8+
{{/*
9+
Define imagePullSecrets for the chart.
10+
*/}}
11+
{{- define "kcp-operator.imagePullSecrets" -}}
12+
{{- range .Values.global.imagePullSecrets }}
13+
{{- if eq (typeOf .) "map[string]interface {}" }}
14+
- {{ toYaml . | trim }}
15+
{{- else }}
16+
- name: {{ . }}
17+
{{- end }}
18+
{{- end }}
19+
{{- end -}}
20+
821
{{/*
922
Create a default fully qualified app name.
1023
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).

charts/kcp-operator/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ spec:
3030
serviceAccountName: {{ include "kcp-operator.serviceAccountName" . }}
3131
securityContext:
3232
{{- toYaml .Values.podSecurityContext | nindent 8 }}
33+
{{- if .Values.global.imagePullSecrets }}
34+
imagePullSecrets:
35+
{{- include "kcp-operator.imagePullSecrets" . | trim | nindent 8 }}
36+
{{- end }}
3337
containers:
3438
- name: {{ .Chart.Name }}
3539
securityContext:

charts/kcp-operator/values.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Default values for kcp-operator.
22
# Declare variables to be passed into your templates.
3-
3+
global:
4+
## Reference to one or more secrets to be used when pulling images
5+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
6+
##
7+
imagePullSecrets: []
8+
# - name: "image-pull-secret"
9+
# or
10+
# - "image-pull-secret"
411
# This is to override the chart name.
512
nameOverride: ""
613
fullnameOverride: ""

charts/kcp/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ v{{- .Chart.AppVersion -}}
3535
{{- $batteries | uniq | join "," -}}
3636
{{- end -}}
3737

38+
{{- define "kcp.imagePullSecrets" -}}
39+
{{- range .Values.global.imagePullSecrets }}
40+
{{- if eq (typeOf .) "map[string]interface {}" }}
41+
- {{ toYaml . | trim }}
42+
{{- else }}
43+
- name: {{ . }}
44+
{{- end }}
45+
{{- end }}
46+
{{- end -}}
47+
3848
{{- define "frontproxy.fullname" -}}
3949
{{- $trimmedName := printf "%s" (include "kcp.fullname" .) | trunc 52 | trimSuffix "-" -}}
4050
{{- printf "%s-front-proxy" $trimmedName | trunc 63 | trimSuffix "-" -}}

charts/kcp/templates/etcd-statefulset.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ spec:
4848
tolerations:
4949
{{- toYaml . | nindent 8 }}
5050
{{- end }}
51+
{{- if .Values.global.imagePullSecrets }}
52+
imagePullSecrets:
53+
{{- include "kcp.imagePullSecrets" . | trim | nindent 8 }}
54+
{{- end }}
5155
containers:
5256
- name: etcd
5357
image: {{ .Values.etcd.image }}:{{ .Values.etcd.tag }}

charts/kcp/templates/front-proxy-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ spec:
6666
tolerations:
6767
{{- toYaml . | nindent 8 }}
6868
{{- end }}
69+
{{- if .Values.global.imagePullSecrets }}
70+
imagePullSecrets:
71+
{{- include "kcp.imagePullSecrets" . | trim | nindent 8 }}
72+
{{- end }}
6973
containers:
7074
- name: kcp-front-proxy
7175
image: "{{ .Values.kcpFrontProxy.image }}:{{- include "frontproxy.version" . }}"

charts/kcp/templates/server-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ spec:
106106
tolerations:
107107
{{- toYaml . | nindent 8 }}
108108
{{- end }}
109+
{{- if .Values.global.imagePullSecrets }}
110+
imagePullSecrets:
111+
{{- include "kcp.imagePullSecrets" . | trim | nindent 8 }}
112+
{{- end }}
109113
containers:
110114
- name: kcp
111115
image: {{ .Values.kcp.image }}:{{- include "kcp.version" . }}

charts/kcp/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
global:
2+
## Reference to one or more secrets to be used when pulling images
3+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
4+
##
5+
imagePullSecrets: []
6+
# - name: "image-pull-secret"
7+
# or
8+
# - "image-pull-secret"
19
externalHostname: ""
210
externalPort: "" # defaults to 8443 for .Values.kcpFrontProxy.service.type "LoadBalancer", 443 otherwise.
311
etcd:

charts/proxy/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
{{- end -}}
2020
{{- end -}}
2121

22+
{{- define "kcp.imagePullSecrets" -}}
23+
{{- range .Values.global.imagePullSecrets }}
24+
{{- if eq (typeOf .) "map[string]interface {}" }}
25+
- {{ toYaml . | trim }}
26+
{{- else }}
27+
- name: {{ . }}
28+
{{- end }}
29+
{{- end }}
30+
{{- end -}}
31+
2232
{{- define "certificates.kcp" -}}
2333
{{- if not (eq .Values.certificates.name "") -}}
2434
{{- $trimmedName := printf "%s" .Values.certificates.name | trunc 58 | trimSuffix "-" -}}

charts/proxy/templates/front-proxy-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ spec:
7272
hostAliases:
7373
{{- toYaml .Values.kcpFrontProxy.hostAliases.values | nindent 6 }}
7474
{{- end }}
75+
{{- if .Values.global.imagePullSecrets }}
76+
imagePullSecrets:
77+
{{- include "kcp.imagePullSecrets" . | trim | nindent 8 }}
78+
{{- end }}
7579
containers:
7680
- name: kcp-front-proxy
7781
image: "{{ .Values.kcpFrontProxy.image }}:{{- include "frontproxy.version" . }}"

charts/proxy/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
global:
2+
## Reference to one or more secrets to be used when pulling images
3+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
4+
##
5+
imagePullSecrets: []
6+
# - name: "image-pull-secret"
7+
# or
8+
# - "image-pull-secret"
19
externalHostname: ""
210
kcpFrontProxy:
311
enabled: true

charts/shard/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
{{- end -}}
2020
{{- end -}}
2121

22+
{{- define "kcp.imagePullSecrets" -}}
23+
{{- range .Values.global.imagePullSecrets }}
24+
{{- if eq (typeOf .) "map[string]interface {}" }}
25+
- {{ toYaml . | trim }}
26+
{{- else }}
27+
- name: {{ . }}
28+
{{- end }}
29+
{{- end }}
30+
{{- end -}}
31+
2232
{{- define "certificates.kcp" -}}
2333
{{- if not (eq .Values.certificates.name "") -}}
2434
{{- $trimmedName := printf "%s" .Values.certificates.name | trunc 58 | trimSuffix "-" -}}

charts/shard/templates/server-deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ spec:
108108
hostAliases:
109109
{{- toYaml .Values.kcp.hostAliases.values | nindent 6 }}
110110
{{- end }}
111+
{{- if .Values.global.imagePullSecrets }}
112+
imagePullSecrets:
113+
{{- include "kcp.imagePullSecrets" . | trim | nindent 8 }}
114+
{{- end }}
111115
containers:
112116
- name: kcp
113117
image: {{ .Values.kcp.image }}:{{- include "kcp.version" . }}

charts/shard/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
global:
2+
## Reference to one or more secrets to be used when pulling images
3+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
4+
##
5+
imagePullSecrets: []
6+
# - name: "image-pull-secret"
7+
# or
8+
# - "image-pull-secret"externalHostname: ""
19
externalHostname: ""
210
etcd:
311
enabled: true

0 commit comments

Comments
 (0)