Skip to content

Commit

Permalink
feat: added customEnv option
Browse files Browse the repository at this point in the history
You can add a default.customEnv list of environment variables to every
service, or a customEnv list for single services.

Ticket: MC-6856

Signed-off-by: Roberto Giovanardi <[email protected]>
  • Loading branch information
oldgiova committed Jan 30, 2024
1 parent 82d01fa commit 3cfbfdb
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 1 deletion.
1 change: 1 addition & 0 deletions mender/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master
* Fix mongodb uri creation when using the mongodb subchart and replicast architecture
* Added customEnv option to set default or per-service custom env variables

## Version 5.4.1
* Upgrade to Mender version `3.7.1`.
Expand Down
11 changes: 11 additions & 0 deletions mender/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,14 @@ Create the name of the service account
{{- default "default" $dot.Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Synopsis:
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.<service>) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}
*/}}
{{- define "mender.customEnvs" -}}
{{- with .customEnvs }}
{{- toYaml . }}
{{- println "" }}
{{- end }}
{{- end -}}
1 change: 1 addition & 0 deletions mender/templates/auditlogs/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ spec:
env:
- name: AUDITLOGS_AUDITLOG_EXPIRE_SECONDS
value: {{ .dot.Values.auditlogs.logRetentionSeconds | int | toString | quote }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.auditlogs) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}
# Supported configuration settings: https://github.com/mendersoftware/auditlogs/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
envFrom:
Expand Down
1 change: 1 addition & 0 deletions mender/templates/create-artifact-worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ spec:
value: "1"
- name: CREATE_ARTIFACT_DEPLOYMENTS_URL
value: http://{{ .Values.deployments.service.name }}:{{ .Values.deployments.service.port }}
{{- include "mender.customEnvs" (merge (deepCopy .Values.create_artifact_worker) (deepCopy (default (dict) .Values.default))) | nindent 8 }}
envFrom:
- prefix: WORKFLOWS_
secretRef:
Expand Down
1 change: 1 addition & 0 deletions mender/templates/deployments/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ spec:
value: "true"
{{- end }}
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.deployments) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/deployments/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
Expand Down
1 change: 1 addition & 0 deletions mender/templates/device-auth/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ spec:
- name: DEVICEAUTH_REDIS_LIMITS_EXPIRE_SEC
value: {{ .dot.Values.useradm.env.DEVICEAUTH_REDIS_LIMITS_EXPIRE_SEC | default "3600" | quote }}
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.device_auth) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/deviceauth/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
Expand Down
1 change: 1 addition & 0 deletions mender/templates/deviceconfig/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ spec:
# Workflows orchestrator address
- name: DEVICECONFIG_WORKFLOWS_URL
value: http://mender-workflows-server:8080/
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.deviceconfig) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/deviceconfig/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
Expand Down
2 changes: 2 additions & 0 deletions mender/templates/deviceconnect/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ spec:
{{.hostname}} https://{{.hostname}} wss://{{.hostname}}
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.deviceconnect) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/deviceconnect/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
envFrom:
Expand Down
2 changes: 2 additions & 0 deletions mender/templates/devicemonitor/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ spec:
- name: DEVICEMONITOR_WORKFLOWS_URL
value: {{ .dot.Values.device_auth.env.DEVICEMONITOR_WORKFLOWS_URL | quote }}

{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.devicemonitor) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/devicemonitor/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
envFrom:
Expand Down
1 change: 1 addition & 0 deletions mender/templates/generate-delta-worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ spec:
value: "1"
- name: GENERATE_DELTA_DEPLOYMENTS_URL
value: http://{{ .Values.deployments.service.name }}:{{ .Values.deployments.service.port }}
{{- include "mender.customEnvs" (merge (deepCopy .Values.generate_delta_worker) (deepCopy (default (dict) .Values.default))) | nindent 8 }}
envFrom:
- prefix: WORKFLOWS_
secretRef:
Expand Down
1 change: 1 addition & 0 deletions mender/templates/gui/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ spec:
- name: HAVE_MONITOR
value: "true"
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .Values.gui) (deepCopy (default (dict) .Values.default))) | nindent 8 }}

{{- if .Values.global.image.username }}
imagePullSecrets:
Expand Down
1 change: 1 addition & 0 deletions mender/templates/inventory/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ spec:
value: {{ .dot.Values.useradm.env.INVENTORY_REDIS_CACHE_EXPIRE_SEC | default "1800" | quote }}
{{- end }}
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.inventory) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/inventory-enterprise/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
Expand Down
2 changes: 2 additions & 0 deletions mender/templates/iot-manager/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ spec:

env:
# Supported configuration settings: https://github.com/mendersoftware/iot-manager/blob/master/config.yaml
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.iot_manager) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Set in order, last value for the key will be used in case duplications.
envFrom:
- prefix: IOT_MANAGER_
Expand Down
1 change: 1 addition & 0 deletions mender/templates/tenantadm/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ spec:
- name: TENANTADM_ENABLE_SELF_SERVICE_SIGN_UP
value: {{ .dot.Values.global.hosted | quote }}
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.tenantadm) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/tenantadm/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
Expand Down
1 change: 1 addition & 0 deletions mender/templates/useradm/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ spec:
- name: USERADM_REDIS_LIMITS_EXPIRE_SEC
value: {{ .dot.Values.useradm.env.USERADM_REDIS_LIMITS_EXPIRE_SEC | default "3600" | quote }}
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.useradm) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/useradm/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
Expand Down
1 change: 1 addition & 0 deletions mender/templates/workflows/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ spec:
value: "true"
{{- end }}
{{- end }}
{{- include "mender.customEnvs" (merge (deepCopy .dot.Values.workflows) (deepCopy (default (dict) .dot.Values.default))) | nindent 4 }}

# Supported configuration settings: https://github.com/mendersoftware/workflows/blob/master/config.yaml
# Set in order, last value for the key will be used in case duplications.
Expand Down
76 changes: 75 additions & 1 deletion mender/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ default:
enabled: false
minAvailable: 1

# custom default envs for every service
customEnvs: []
# - name: LOG_LEVEL
# value: WARN

serviceAccount:
create: false
name:
Expand Down Expand Up @@ -290,6 +295,11 @@ deployments:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

device_auth:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -358,6 +368,11 @@ device_auth:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

# Generate Delta Worker feature
# Experimental feature, still in beta
# will be released in the next Mender versions
Expand All @@ -383,6 +398,11 @@ generate_delta_worker:
nodeSelector: {}
priorityClassName: ""

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

gui:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -418,6 +438,11 @@ gui:
runAsUser: 65534
priorityClassName: ""

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

inventory:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -472,6 +497,11 @@ inventory:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

tenantadm:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -539,6 +569,10 @@ tenantadm:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

useradm:
enabled: true
Expand Down Expand Up @@ -608,6 +642,11 @@ useradm:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

workflows:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -658,6 +697,11 @@ workflows:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

create_artifact_worker:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -687,6 +731,11 @@ create_artifact_worker:
runAsUser: 65534
priorityClassName: ""

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

auditlogs:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -724,7 +773,7 @@ auditlogs:
hpa: {}
pdb: {}
priorityClassName: ""

## Migration Job

## auditlogs.migrationRestartPolicy
Expand All @@ -741,6 +790,11 @@ auditlogs:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

iot_manager:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -793,6 +847,11 @@ iot_manager:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

deviceconnect:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -847,6 +906,11 @@ deviceconnect:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

deviceconfig:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -899,6 +963,11 @@ deviceconfig:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

devicemonitor:
enabled: true
podAnnotations: {}
Expand Down Expand Up @@ -951,6 +1020,11 @@ devicemonitor:
# cpu: 150m
# memory: 64M

# custom envs
customEnvs: []
# - name: LOG_LEVEL
# value: DEBUG

# Redis as a subchart
# Using a bitnami sub-chart by default = test usage only
# It's recommended to use a suitable Redis Cluster for Production
Expand Down

0 comments on commit 3cfbfdb

Please sign in to comment.