Skip to content

Commit

Permalink
add extra environment variable definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ekneg54 committed Jul 11, 2024
1 parent a9e59c7 commit 416c224
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions charts/logprep/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ spec:
- name: REQUESTS_CA_BUNDLE
value: /home/logprep/certificates/{{ .Values.secrets.certificates.name }}
{{- end }}
{{- range $key, $value := .Values.environment }}
- name: {{ $key }}
value: {{ $value }}
{{- end }}
volumeMounts:
- name: logprep-temp
mountPath: /tmp
Expand Down
9 changes: 9 additions & 0 deletions charts/logprep/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ securityContext:
# name: logprep-image-pull-secret # Name of the secret containing the image pull secret
secrets: {}

# extra environment variables in format key: value
# Example:
#
# environment:
# MY_ENV_VAR: "my value"
# MY_OTHER_ENV_VAR: "my other value"
#
environment: {}

# Boolean to signal to use affinity to avoid deploying multiple instances of the
# pod on the same node
affinity: false
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/charts/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,12 @@ def test_extra_secrets_are_mounted(self):
mounts = self.deployment["spec.template.spec.containers.0.volumeMounts"]
mount = [mount for mount in mounts if mount["name"] == "mysecret"]
assert mount

def test_environment_variables_are_populated(self):
logprep_values = {"environment": {"MY_VAR": "my_value", "MY_OTHER_VAR": "my_other_value"}}
self.manifests = self.render_chart("logprep", logprep_values)
env = self.deployment["spec.template.spec.containers.0.env"]
my_var = [variable for variable in env if variable["name"] == "MY_VAR"].pop()
assert my_var["value"] == "my_value"
my_var = [variable for variable in env if variable["name"] == "MY_OTHER_VAR"].pop()
assert my_var["value"] == "my_other_value"

0 comments on commit 416c224

Please sign in to comment.