Skip to content

Commit

Permalink
Avoid unnecessary pod restart on each helm chart version
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Dec 10, 2023
1 parent 4619042 commit 6680dee
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 31 deletions.
6 changes: 3 additions & 3 deletions helm/oauth2-proxy/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 18.3.2
digest: sha256:c4d7208b098ca3c44f960f02fb0e505ac6493cf00c6539ee7bf0a603371d9959
generated: "2023-11-13T12:24:54.470708+01:00"
version: 18.3.3
digest: sha256:865602aa87ca1148f943df10e3151f64e9f52cdef7be2109b6cf9774b4c356be
generated: "2023-12-10T13:18:26.852349+01:00"
28 changes: 28 additions & 0 deletions helm/oauth2-proxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,31 @@ Workaround for EKS https://github.com/aws/eks-distro/issues/1128
{{- printf "%s.%s" .Capabilities.KubeVersion.Major (.Capabilities.KubeVersion.Minor | replace "+" "") -}}
{{- end -}}
{{- end -}}

{{- define "oauth2-proxy.alpha-config" -}}
---
server:
BindAddress: '0.0.0.0:4180'
{{- if .Values.alphaConfig.serverConfigData }}
{{- toYaml .Values.alphaConfig.serverConfigData | nindent 6 }}
{{- end }}
{{- if .Values.metrics.enabled }}
metricsServer:
BindAddress: '0.0.0.0:44180'
{{- if .Values.alphaConfig.metricsConfigData }}
{{- toYaml .Values.alphaConfig.metricsConfigData | nindent 6 }}
{{- end }}
{{- end }}
{{- if .Values.alphaConfig.configData }}
{{- toYaml .Values.alphaConfig.configData | nindent 4 }}
{{- end }}
{{- if .Values.alphaConfig.configFile }}
{{- tpl .Values.alphaConfig.configFile $ | nindent 4 }}
{{- end }}
{{- end -}}

{{- define "oauth2-proxy.secrets" -}}
cookie-secret: {{ tpl .Values.config.cookieSecret $ | b64enc | quote }}
client-secret: {{ tpl .Values.config.clientSecret $ | b64enc | quote }}
client-id: {{ tpl .Values.config.clientID $ | b64enc | quote }}
{{- end -}}
10 changes: 6 additions & 4 deletions helm/oauth2-proxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/config: {{ tpl .Values.config.configFile $ | sha256sum }}
{{- if .Values.alphaConfig.enabled }}
checksum/alpha-config: {{ include (print $.Template.BasePath "/secret-alpha.yaml") . | sha256sum }}
checksum/alpha-config: {{ include "oauth2-proxy.alpha-config" . | sha256sum }}
{{- end }}
{{- if .Values.authenticatedEmailsFile.enabled }}
checksum/config-emails: {{ include (print $.Template.BasePath "/configmap-authenticated-emails-file.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end }}
checksum/secret: {{ include "oauth2-proxy.secrets" . | sha256sum }}
checksum/google-secret: {{ include (print $.Template.BasePath "/google-secret.yaml") . | sha256sum }}
checksum/redis-secret: {{ include (print $.Template.BasePath "/redis-secret.yaml") . | sha256sum }}
{{- if .Values.htpasswdFile.enabled }}
checksum/htpasswd: {{ include (print $.Template.BasePath "/secret-htpasswd-file.yaml") . | sha256sum }}
checksum/htpasswd: {{ toYaml .Values.htpasswdFile.entries | sha256sum }}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
Expand Down
23 changes: 2 additions & 21 deletions helm/oauth2-proxy/templates/secret-alpha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,6 @@ metadata:
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}-alpha
namespace: {{ template "oauth2-proxy.namespace" $ }}
stringData:
oauth2_proxy.yml: |
---
server:
BindAddress: '0.0.0.0:4180'
{{- if .Values.alphaConfig.serverConfigData }}
{{- toYaml .Values.alphaConfig.serverConfigData | nindent 6 }}
{{- end }}
{{- if .Values.metrics.enabled }}
metricsServer:
BindAddress: '0.0.0.0:44180'
{{- if .Values.alphaConfig.metricsConfigData }}
{{- toYaml .Values.alphaConfig.metricsConfigData | nindent 6 }}
{{- end }}
{{- end }}
{{- if .Values.alphaConfig.configData }}
{{- toYaml .Values.alphaConfig.configData | nindent 4 }}
{{- end }}
{{- if .Values.alphaConfig.configFile }}
{{- tpl .Values.alphaConfig.configFile $ | nindent 4 }}
{{- end }}
data:
oauth2_proxy.yml: {{ include "oauth2-proxy.alpha-config" . | b64enc | quote }}
{{- end }}
4 changes: 1 addition & 3 deletions helm/oauth2-proxy/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ metadata:
namespace: {{ template "oauth2-proxy.namespace" $ }}
type: Opaque
data:
cookie-secret: {{ tpl .Values.config.cookieSecret $ | b64enc | quote }}
client-secret: {{ tpl .Values.config.clientSecret $ | b64enc | quote }}
client-id: {{ tpl .Values.config.clientID $ | b64enc | quote }}
{{- include "oauth2-proxy.secrets" . | nindent 2 }}
{{- end -}}

0 comments on commit 6680dee

Please sign in to comment.