Skip to content

Commit f021563

Browse files
committed
Add pull secret for default backend
1 parent 161eff3 commit f021563

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

kubernetes-ingress/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ Encode an imagePullSecret string.
5353
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.controller.imageCredentials.registry (printf "%s:%s" .Values.controller.imageCredentials.username .Values.controller.imageCredentials.password | b64enc) | b64enc }}
5454
{{- end }}
5555

56+
{{/*
57+
Encode an imagePullSecret string for the default backend.
58+
*/}}
59+
{{- define "kubernetes-ingress.defaultBackend.imagePullSecret" }}
60+
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.defaultBackend.imageCredentials.registry (printf "%s:%s" .Values.defaultBackend.imageCredentials.username .Values.defaultBackend.imageCredentials.password | b64enc) | b64enc }}
61+
{{- end }}
62+
5663
{{/*
5764
Generate default certificate for HAProxy.
5865
*/}}

kubernetes-ingress/templates/default-backend-deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ spec:
5151
topologySpreadConstraints:
5252
{{- toYaml . | nindent 8 }}
5353
{{- end }}
54+
{{- if .Values.defaultBackend.imageCredentials.registry }}
55+
imagePullSecrets:
56+
- name: {{ template "kubernetes-ingress.defaultBackend.fullname" . }}
57+
{{- else if .Values.defaultBackend.existingImagePullSecret }}
58+
imagePullSecrets:
59+
- name: {{ .Values.defaultBackend.existingImagePullSecret }}
60+
{{- end }}
5461
{{- if .Values.controller.priorityClassName }}
5562
priorityClassName: {{ .Values.controller.priorityClassName }}
5663
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{/*
2+
Copyright 2019 HAProxy Technologies LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/}}
16+
17+
{{- if .Values.defaultBackend.imageCredentials.registry }}
18+
apiVersion: v1
19+
kind: Secret
20+
metadata:
21+
name: {{ template "kubernetes-ingress.defaultBackend.fullname" . }}
22+
namespace: {{ .Release.Namespace }}
23+
labels:
24+
app.kubernetes.io/name: {{ template "kubernetes-ingress.name" . }}
25+
helm.sh/chart: {{ template "kubernetes-ingress.chart" . }}
26+
app.kubernetes.io/managed-by: {{ .Release.Service }}
27+
app.kubernetes.io/instance: {{ .Release.Name }}
28+
app.kubernetes.io/version: {{ .Chart.AppVersion }}
29+
type: kubernetes.io/dockerconfigjson
30+
data:
31+
.dockerconfigjson: {{ template "kubernetes-ingress.defaultBackend.imagePullSecret" . }}
32+
{{- end }}

kubernetes-ingress/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,14 @@ defaultBackend:
531531
# metricName: haproxy_backend_current_sessions
532532
# targetAverageValue: 2000
533533

534+
## Private Registry configuration
535+
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
536+
imageCredentials:
537+
registry: null
538+
username: null
539+
password: null
540+
existingImagePullSecret: null
541+
534542
## Listener port configuration
535543
## ref: https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/
536544
containerPort: 8080

0 commit comments

Comments
 (0)