Skip to content

Commit

Permalink
be able to set custom env vars on server pod
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazzitelli committed Oct 16, 2024
1 parent f583955 commit 8dac6f7
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crd-docs/cr/kiali.io_v1alpha1_kiali.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ spec:
# default: configmap_annotations is empty
configmap_annotations:
strategy.spinnaker.io/versioned: "false"
# default: custom_envs is an empty list
custom_envs:
- name: "HTTP_PROXY"
value: "http://my.proxy.com:1234"
- name: "NO_PROXY"
value: "hostname.example.com"
# default: custom_secrets is an empty list
custom_secrets:
- name: "a-custom-secret"
Expand Down
13 changes: 13 additions & 0 deletions crd-docs/crd/kiali.io_kialis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,19 @@ spec:
description: "Custom annotations to be created on the Kiali ConfigMap."
type: object
x-kubernetes-preserve-unknown-fields: true
custom_envs:
description: "Defines additional environment variables to be set in the Kiali server pod. This is typically used for (but not limited to) setting proxy environment variables such as HTTP_PROXY, HTTPS_PROXY, and/or NO_PROXY."
type: array
items:
required: ["name", "value"]
type: object
properties:
name:
description: "The name of the custom environment variable."
type: string
value:
description: "The value of the custom environment variable."
type: string
custom_secrets:
description: |
Defines additional secrets that are to be mounted in the Kiali pod.
Expand Down
21 changes: 21 additions & 0 deletions molecule/config-values-test/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@
set_fact:
current_kiali_cr: "{{ current_kiali_cr | combine({'spec': {'deployment': {'custom_secrets': custom_secrets}}}, recursive=True) }}"

- name: Add custom_envs
vars:
custom_envs:
- name: CUSTOM_ENV_VAR_ONE
value: "true"
- name: CUSTOM_ENV_VAR_2
value: "12345"
- name: CUSTOM_ENV_VAR_THREE
value: "a: b// :123 *,X,Y,Z"
set_fact:
current_kiali_cr: "{{ current_kiali_cr | combine({'spec': {'deployment': {'custom_envs': custom_envs}}}, recursive=True) }}"

- name: Set deployment.resources to empty map which means we want to not define the pod resources at all
set_fact:
current_kiali_cr: "{{ current_kiali_cr | combine({'spec': {'deployment': {'resources': {}}}}, recursive=True) }}"
Expand Down Expand Up @@ -378,3 +390,12 @@
- kiali_configmap.extensions | length == 1
- kiali_configmap.extensions[0].name == "skupper"
- kiali_configmap.extensions[0].enabled == False

- name: Test custom_envs
vars:
kiali_pod_envs: "{{ kiali_pod.resources[0].spec.containers[0].env }}"
assert:
that:
- kiali_pod_envs | selectattr('name', 'equalto', 'CUSTOM_ENV_VAR_ONE') | selectattr('value', 'equalto', 'true') | list | length > 0
- kiali_pod_envs | selectattr('name', 'equalto', 'CUSTOM_ENV_VAR_2') | selectattr('value', 'equalto', '12345') | list | length > 0
- "'a: b// :123 *,X,Y,Z' in kiali_pod_envs | selectattr('name', 'equalto', 'CUSTOM_ENV_VAR_THREE') | map(attribute='value') | list"
1 change: 1 addition & 0 deletions roles/default/kiali-deploy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ kiali_defaults:
pod_anti: {}
cluster_wide_access: true
configmap_annotations: {}
custom_envs: []
custom_secrets: []
discovery_selectors: {}
dns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ spec:
value: "{{ kiali_vars.deployment.logger.sampler_rate }}"
- name: LOG_TIME_FIELD_FORMAT
value: "{{ kiali_vars.deployment.logger.time_field_format }}"
{% for env in kiali_vars.deployment.custom_envs %}
- name: "{{ env.name | quote }}"
value: "{{ env.value | quote }}"
{% endfor %}
volumeMounts:
- name: kiali-configuration
mountPath: "/kiali-configuration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ spec:
value: "{{ kiali_vars.deployment.logger.sampler_rate }}"
- name: LOG_TIME_FIELD_FORMAT
value: "{{ kiali_vars.deployment.logger.time_field_format }}"
{% for env in kiali_vars.deployment.custom_envs %}
- name: "{{ env.name | quote }}"
value: "{{ env.value | quote }}"
{% endfor %}
volumeMounts:
- name: kiali-configuration
mountPath: "/kiali-configuration"
Expand Down

0 comments on commit 8dac6f7

Please sign in to comment.