From d0107348966146bc4896f8a5ced7a9b3a3308047 Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Wed, 28 Jun 2023 14:04:53 +0200 Subject: [PATCH] feat(os2mo): [#48311] template environment variables directly Previously, environment variables were templated into a ConfigMap which was referenced through an `envFrom` in the deployment. Unfortunately, Kubernetes does not restart deployments on changes to their referenced ConfigMaps[1], so this indirection means that deployments have to be restarted manually every time a change is made - something that is very easy to forget in an otherwise GitOpsy workflow. The `environment_containing_json` does not seem to serve any purpose, but was probably copied from an old method of templating the ConfigMap using a for-loop instead of `toYaml`. [1] https://github.com/kubernetes/kubernetes/issues/22368 --- os2mo/templates/mo/configmap.yaml | 16 ---------------- os2mo/templates/mo/deployment.yaml | 25 ++++++++++++++++--------- os2mo/templates/mo/json-config.yaml | 14 -------------- 3 files changed, 16 insertions(+), 39 deletions(-) delete mode 100644 os2mo/templates/mo/configmap.yaml delete mode 100644 os2mo/templates/mo/json-config.yaml diff --git a/os2mo/templates/mo/configmap.yaml b/os2mo/templates/mo/configmap.yaml deleted file mode 100644 index 92a2da7..0000000 --- a/os2mo/templates/mo/configmap.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-FileCopyrightText: Magenta ApS -# -# SPDX-License-Identifier: MPL-2.0 ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: mo-config - {{- with .Values.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -data: -{{- range $key, $val := $.Values.os2mo.environment }} - {{ $key | quote }}: {{ $val | quote }} -{{- end }} diff --git a/os2mo/templates/mo/deployment.yaml b/os2mo/templates/mo/deployment.yaml index 87ee2e7..8a9b826 100644 --- a/os2mo/templates/mo/deployment.yaml +++ b/os2mo/templates/mo/deployment.yaml @@ -104,12 +104,14 @@ spec: - name: CONFDB_SHOW_ORG_UNIT_BUTTON value: {{ .Values.sdtool.enabled | quote }} - envFrom: - - configMapRef: - name: mo-config - - configMapRef: - name: mo-json-config - + {{- range $name, $value := .Values.os2mo.environment }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} + {{- range $name, $value := .Values.os2mo.environment_containing_json }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} ports: - containerPort: 5000 resources: @@ -220,9 +222,14 @@ spec: secretKeyRef: name: {{ .Values.database.mox.secret }} key: db_password - envFrom: - - configMapRef: - name: mo-config + {{- range $name, $value := .Values.os2mo.environment }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} + {{- range $name, $value := .Values.os2mo.environment_containing_json }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} resources: {{- toYaml .Values.os2mo.resources | nindent 12 }} diff --git a/os2mo/templates/mo/json-config.yaml b/os2mo/templates/mo/json-config.yaml deleted file mode 100644 index dd29184..0000000 --- a/os2mo/templates/mo/json-config.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-FileCopyrightText: Magenta ApS -# -# SPDX-License-Identifier: MPL-2.0 ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: mo-json-config - {{- with .Values.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -data: -{{ toYaml .Values.os2mo.environment_containing_json | indent 2 }}