From 08714b6037420d60c19e27ecfa4f8bbe62386a69 Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Wed, 28 Jun 2023 13:58:45 +0200 Subject: [PATCH] feat(ad_to_mo_sync): [#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 --- .../integrations/ad_to_mo_sync/config.yaml | 16 ---------------- .../integrations/ad_to_mo_sync/deployment.yaml | 13 ++++++++----- .../integrations/ad_to_mo_sync/json-config.yaml | 14 -------------- 3 files changed, 8 insertions(+), 35 deletions(-) delete mode 100644 os2mo/templates/integrations/ad_to_mo_sync/config.yaml delete mode 100644 os2mo/templates/integrations/ad_to_mo_sync/json-config.yaml diff --git a/os2mo/templates/integrations/ad_to_mo_sync/config.yaml b/os2mo/templates/integrations/ad_to_mo_sync/config.yaml deleted file mode 100644 index 027147a..0000000 --- a/os2mo/templates/integrations/ad_to_mo_sync/config.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-FileCopyrightText: Magenta ApS -# -# SPDX-License-Identifier: MPL-2.0 ---- -{{- if .Values.ad_to_mo_sync.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: ad-to-mo-sync-config - {{- with .Values.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -data: -{{ toYaml .Values.ad_to_mo_sync.environment | indent 2 }} -{{- end }} diff --git a/os2mo/templates/integrations/ad_to_mo_sync/deployment.yaml b/os2mo/templates/integrations/ad_to_mo_sync/deployment.yaml index 849a281..18dae2f 100644 --- a/os2mo/templates/integrations/ad_to_mo_sync/deployment.yaml +++ b/os2mo/templates/integrations/ad_to_mo_sync/deployment.yaml @@ -91,11 +91,14 @@ spec: value: {{ required "AD_SEARCH_BASE must be set" .Values.ad_to_mo_sync.ad_search_base | quote }} - name: AD_MAPPINGS value: {{ required "AD_MAPPINGS must be set" .Values.ad_to_mo_sync.ad_mappings | quote }} - envFrom: - - configMapRef: - name: ad-to-mo-sync-config - - configMapRef: - name: ad-to-mo-sync-json-config + {{- range $name, $value := .Values.ad_to_mo_sync.environment }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} + {{- range $name, $value := .Values.ad_to_mo_sync.environment_containing_json }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} ports: - containerPort: 8000 resources: diff --git a/os2mo/templates/integrations/ad_to_mo_sync/json-config.yaml b/os2mo/templates/integrations/ad_to_mo_sync/json-config.yaml deleted file mode 100644 index 9a36f0d..0000000 --- a/os2mo/templates/integrations/ad_to_mo_sync/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: ad-to-mo-sync-json-config - {{- with .Values.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -data: -{{ toYaml .Values.ad_to_mo_sync.environment_containing_json | indent 2 }}