From d67aa65134ff450bff949382d91a8aea087bb9eb Mon Sep 17 00:00:00 2001 From: Lukas Knuth Date: Thu, 27 Apr 2023 11:12:47 +0200 Subject: [PATCH] Fixing Helm Chart and consistency (#20) * Remove empty line output in Service * Secret requires base64 encoding, or use `stringData` and let K8s handle that. * Use `with` to change scope * Don't render environments with no defaults at all. * Consistent indention of with blocks. --- helm-chart/templates/deployment.yaml | 34 ++++++++++++++++------------ helm-chart/templates/secrets.yaml | 2 +- helm-chart/templates/service.yaml | 2 +- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/helm-chart/templates/deployment.yaml b/helm-chart/templates/deployment.yaml index 6497638..965302f 100644 --- a/helm-chart/templates/deployment.yaml +++ b/helm-chart/templates/deployment.yaml @@ -13,27 +13,27 @@ spec: {{- include "supertokens.selectorLabels" . | nindent 6 }} template: metadata: - {{- if .Values.podAnnotations }} + {{- with .Values.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} labels: {{- include "supertokens.selectorLabels" . | nindent 8 }} spec: - {{- if .Values.imagePullSecrets }} + {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "supertokens.serviceAccountName" . }} - {{- if .Values.podSecurityContext }} + {{- with .Values.podSecurityContext }} securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- toYaml . | nindent 8 }} {{- end }} containers: - name: {{ .Chart.Name }} - {{- if .Values.securityContext }} + {{- with .Values.securityContext }} securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} + {{- toYaml . | nindent 12 }} # {{ else }} # securityContext: # readOnlyRootFilesystem: true @@ -41,10 +41,14 @@ spec: image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: + {{- if .Values.database.schema }} - name: "POSTGRESQL_TABLE_SCHEMA" value: {{ quote .Values.database.schema }} + {{- end }} + {{- if .Values.database.connectionPoolSize }} - name: "POSTGRESQL_CONNECTION_POOL_SIZE" value: {{ quote .Values.database.connectionPoolSize }} + {{- end }} - name: "SUPERTOKENS_PORT" value: {{ quote .Values.service.port }} - name: "ACCESS_TOKEN_VALIDITY" @@ -80,19 +84,19 @@ spec: protocol: TCP livenessProbe: {{ .Values.livenessProbe | toYaml | nindent 12 }} readinessProbe: {{ .Values.readinessProbe | toYaml | nindent 12 }} - {{ if .Values.resources }} + {{- with .Values.resources }} resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- end -}} - {{- if .Values.nodeSelector }} + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} - {{- end -}} - {{- if .Values.affinity }} + {{- end }} + {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} - {{- end -}} - {{- if .Values.tolerations }} + {{- end }} + {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end -}} \ No newline at end of file + {{- end }} \ No newline at end of file diff --git a/helm-chart/templates/secrets.yaml b/helm-chart/templates/secrets.yaml index 3f81c3f..c216aac 100644 --- a/helm-chart/templates/secrets.yaml +++ b/helm-chart/templates/secrets.yaml @@ -6,7 +6,7 @@ metadata: labels: {{ include "supertokens.labels" . | indent 4}} type: Opaque -data: +stringData: POSTGRESQL_DATABASE_NAME: {{ quote .Values.database.name }} POSTGRESQL_PORT: {{ quote .Values.database.port }} POSTGRESQL_HOST: {{ quote .Values.database.host }} diff --git a/helm-chart/templates/service.yaml b/helm-chart/templates/service.yaml index 6f62be6..9995240 100644 --- a/helm-chart/templates/service.yaml +++ b/helm-chart/templates/service.yaml @@ -9,7 +9,7 @@ spec: ports: - port: {{ .Values.service.port }} targetPort: {{ .Values.service.targetPort }} - {{ if .Values.service.nodePort -}} + {{- if .Values.service.nodePort }} nodePort: {{ .Values.service.nodePort }} {{- end }} protocol: TCP