diff --git a/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml b/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml index b7c88baa..543a1e26 100644 --- a/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml +++ b/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml @@ -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" diff --git a/crd-docs/crd/kiali.io_kialis.yaml b/crd-docs/crd/kiali.io_kialis.yaml index 89a44a09..94a73e3c 100644 --- a/crd-docs/crd/kiali.io_kialis.yaml +++ b/crd-docs/crd/kiali.io_kialis.yaml @@ -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. diff --git a/molecule/config-values-test/converge.yml b/molecule/config-values-test/converge.yml index d2d02148..061a971a 100644 --- a/molecule/config-values-test/converge.yml +++ b/molecule/config-values-test/converge.yml @@ -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) }}" @@ -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" diff --git a/roles/default/kiali-deploy/defaults/main.yml b/roles/default/kiali-deploy/defaults/main.yml index 7dc1540e..7b50fd1f 100644 --- a/roles/default/kiali-deploy/defaults/main.yml +++ b/roles/default/kiali-deploy/defaults/main.yml @@ -56,6 +56,7 @@ kiali_defaults: pod_anti: {} cluster_wide_access: true configmap_annotations: {} + custom_envs: [] custom_secrets: [] discovery_selectors: {} dns: diff --git a/roles/default/kiali-deploy/templates/kubernetes/deployment.yaml b/roles/default/kiali-deploy/templates/kubernetes/deployment.yaml index 3bfcffb5..86387709 100644 --- a/roles/default/kiali-deploy/templates/kubernetes/deployment.yaml +++ b/roles/default/kiali-deploy/templates/kubernetes/deployment.yaml @@ -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 }}" + value: "{{ env.value }}" +{% endfor %} volumeMounts: - name: kiali-configuration mountPath: "/kiali-configuration" diff --git a/roles/default/kiali-deploy/templates/openshift/deployment.yaml b/roles/default/kiali-deploy/templates/openshift/deployment.yaml index 7d5a4f3b..de40c8ce 100644 --- a/roles/default/kiali-deploy/templates/openshift/deployment.yaml +++ b/roles/default/kiali-deploy/templates/openshift/deployment.yaml @@ -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 }}" + value: "{{ env.value }}" +{% endfor %} volumeMounts: - name: kiali-configuration mountPath: "/kiali-configuration"