From 11091bff1dfbf40e58d6e9ce577268f55e9a27dd Mon Sep 17 00:00:00 2001 From: Nick Zelei <2420177+nickzelei@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:28:59 -0700 Subject: [PATCH] Adds extraEnvVars to api deployment init container for db migrations (#2717) Co-authored-by: Kenza B --- backend/charts/api/README.md | 3 ++- backend/charts/api/templates/deployment.yaml | 25 ++++++++++++++++++++ backend/charts/api/values.yaml | 4 +++- charts/neosync/README.md | 3 ++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/backend/charts/api/README.md b/backend/charts/api/README.md index 585ed7d062..e88b894b80 100644 --- a/backend/charts/api/README.md +++ b/backend/charts/api/README.md @@ -36,7 +36,7 @@ A Helm chart for the Neosync Backend API | db.port | int | `5432` | The database port | | db.username | string | `nil` | The username that will be used for authentication | | deploymentAnnotations | object | `{}` | Provide a map of deployment annotations that will be attached to the deployment's annotations | -| extraEnvVars | list | `[]` | Provide extra environment variables that will be applied to the deployment. | +| extraEnvVars | list | `[]` | Provide extra environment variables that will be applied to the deployment's user-container. | | fullnameOverride | string | `nil` | Fully overrides the chart name | | host | string | `"0.0.0.0"` | Sets the host that the backend will listen on. 0.0.0.0 is common for Kubernetes workloads. | | image.pullPolicy | string | `nil` | Overrides the default K8s pull policy | @@ -58,6 +58,7 @@ A Helm chart for the Neosync Backend API | migrations.db.port | int | `5432` | The database port | | migrations.db.schemaDir | string | `"/migrations"` | The directory where the migrations are located. | | migrations.db.username | string | `nil` | The username that will be used for authentication | +| migrations.extraEnvVars | list | `[]` | Provide extra environment variables that will be applied to the migration init container. | | nameOverride | string | `nil` | Override the name specified on the Chart, which defaults to .Chart.Name | | neosyncCloud.enabled | bool | `false` | Whether or not this is NeosyncCloud | | neosyncCloud.workerApiKeys | list | `[]` | Worker API keys that have been allowlisted to for use | diff --git a/backend/charts/api/templates/deployment.yaml b/backend/charts/api/templates/deployment.yaml index 66912f7c84..a1d437a2ad 100644 --- a/backend/charts/api/templates/deployment.yaml +++ b/backend/charts/api/templates/deployment.yaml @@ -82,6 +82,31 @@ spec: args: - migrate - up + env: + {{- with .Values.migrations.extraEnvVars }} + {{- range .}} + - name: {{ .name }} + {{- if .value }} + value: {{ .value | quote }} + {{- else if .valueFrom }} + valueFrom: + {{- if .valueFrom.secretKeyRef }} + secretKeyRef: + name: {{ .valueFrom.secretKeyRef.name }} + key: {{ .valueFrom.secretKeyRef.key }} + {{- end }} + {{- if .valueFrom.configMapKeyRef }} + configMapKeyRef: + name: {{ .valueFrom.configMapKeyRef.name }} + key: {{ .valueFrom.configMapKeyRef.key }} + {{- end }} + {{- if .valueFrom.fieldRef }} + fieldRef: + fieldPath: {{ .valueFrom.fieldRef.fieldPath }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} envFrom: - secretRef: diff --git a/backend/charts/api/values.yaml b/backend/charts/api/values.yaml index 2568617c86..14b8199b58 100644 --- a/backend/charts/api/values.yaml +++ b/backend/charts/api/values.yaml @@ -81,6 +81,8 @@ migrations: migrationsTableQuoted: false # -- Extra database options that will be appended to the query string options: + # -- Provide extra environment variables that will be applied to the migration init container. + extraEnvVars: [] # Set requests and limits on the backend to change its performance resources: @@ -237,7 +239,7 @@ protometrics: # -- The strategy to use when rolling out new replicas updateStrategy: -# -- Provide extra environment variables that will be applied to the deployment. +# -- Provide extra environment variables that will be applied to the deployment's user-container. extraEnvVars: [] # -- Provide sidecars that will be appended directly to the deployment next to the user-container diff --git a/charts/neosync/README.md b/charts/neosync/README.md index 15e3be2786..ac05375639 100644 --- a/charts/neosync/README.md +++ b/charts/neosync/README.md @@ -44,7 +44,7 @@ A Helm chart for Neosync that contains the api, app, and worker | api.db.port | int | `5432` | The database port | | api.db.username | string | `nil` | The username that will be used for authentication | | api.deploymentAnnotations | object | `{}` | Provide a map of deployment annotations that will be attached to the deployment's annotations | -| api.extraEnvVars | list | `[]` | Provide extra environment variables that will be applied to the deployment. | +| api.extraEnvVars | list | `[]` | Provide extra environment variables that will be applied to the deployment's user-container. | | api.fullnameOverride | string | `nil` | Fully overrides the chart name | | api.host | string | `"0.0.0.0"` | Sets the host that the backend will listen on. 0.0.0.0 is common for Kubernetes workloads. | | api.image.pullPolicy | string | `nil` | Overrides the default K8s pull policy | @@ -66,6 +66,7 @@ A Helm chart for Neosync that contains the api, app, and worker | api.migrations.db.port | int | `5432` | The database port | | api.migrations.db.schemaDir | string | `"/migrations"` | The directory where the migrations are located. | | api.migrations.db.username | string | `nil` | The username that will be used for authentication | +| api.migrations.extraEnvVars | list | `[]` | Provide extra environment variables that will be applied to the migration init container. | | api.nameOverride | string | `nil` | Override the name specified on the Chart, which defaults to .Chart.Name | | api.neosyncCloud.enabled | bool | `false` | Whether or not this is NeosyncCloud | | api.neosyncCloud.workerApiKeys | list | `[]` | Worker API keys that have been allowlisted to for use |