From 8e7f760186661fe4dd25062842c073e7b37c79e5 Mon Sep 17 00:00:00 2001 From: John Mazzitelli Date: Wed, 22 May 2024 17:23:06 -0400 Subject: [PATCH] Support custom headers for tracing backend requests (#769) part of: https://github.com/kiali/kiali/issues/7266 --- crd-docs/cr/kiali.io_v1alpha1_kiali.yaml | 3 +++ crd-docs/crd/kiali.io_kialis.yaml | 4 ++++ molecule/null-cr-values-test/converge.yml | 1 + roles/default/kiali-deploy/defaults/main.yml | 1 + roles/default/kiali-deploy/tasks/snake_camel_case.yaml | 6 ++++++ 5 files changed, 15 insertions(+) diff --git a/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml b/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml index 0e67b73a..7f9e3e73 100644 --- a/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml +++ b/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml @@ -346,6 +346,9 @@ spec: type: "none" use_kiali_token: false username: "" + # default: custom_headers is empty + custom_headers: + customHeader1: "customHeader1Value" enabled: true grpc_port: 9095 health_check_url: "" diff --git a/crd-docs/crd/kiali.io_kialis.yaml b/crd-docs/crd/kiali.io_kialis.yaml index d67aeeca..e3eb1d35 100644 --- a/crd-docs/crd/kiali.io_kialis.yaml +++ b/crd-docs/crd/kiali.io_kialis.yaml @@ -944,6 +944,10 @@ spec: username: description: "Username to be used when making requests to the Tracing server with `basic` authentication." type: string + custom_headers: + description: "A set of name/value settings that will be passed as headers when requests are sent to the Tracing backend." + type: object + x-kubernetes-preserve-unknown-fields: true enabled: description: "When true, connections to the Tracing server are enabled. `in_cluster_url` and/or `url` need to be provided." type: boolean diff --git a/molecule/null-cr-values-test/converge.yml b/molecule/null-cr-values-test/converge.yml index a4aa2d6a..2f6e267b 100644 --- a/molecule/null-cr-values-test/converge.yml +++ b/molecule/null-cr-values-test/converge.yml @@ -45,6 +45,7 @@ - kiali_configmap.external_services.prometheus.url != "" - kiali_configmap.external_services.prometheus.custom_headers | length == 0 - kiali_configmap.external_services.prometheus.query_scope | length == 0 + - kiali_configmap.external_services.tracing.custom_headers | length == 0 - kiali_configmap.external_services.tracing.query_scope | length == 0 - kiali_configmap.identity.cert_file is defined - kiali_configmap.identity.private_key_file is defined diff --git a/roles/default/kiali-deploy/defaults/main.yml b/roles/default/kiali-deploy/defaults/main.yml index 67afffae..f04258e5 100644 --- a/roles/default/kiali-deploy/defaults/main.yml +++ b/roles/default/kiali-deploy/defaults/main.yml @@ -224,6 +224,7 @@ kiali_defaults: type: "none" use_kiali_token: false username: "" + custom_headers: {} enabled: true grpc_port: 9095 health_check_url: "" diff --git a/roles/default/kiali-deploy/tasks/snake_camel_case.yaml b/roles/default/kiali-deploy/tasks/snake_camel_case.yaml index 31420a4e..3a05b626 100644 --- a/roles/default/kiali-deploy/tasks/snake_camel_case.yaml +++ b/roles/default/kiali-deploy/tasks/snake_camel_case.yaml @@ -137,4 +137,10 @@ {% set kiali_vars=kiali_vars | combine({'deployment': {'custom_secrets': current_cr.spec.deployment.custom_secrets}}, recursive=True) %} {% endif %} {# #} + {# external_services.tracing.custom_headers #} + {% if kiali_vars.external_services.tracing.custom_headers is defined and kiali_vars.external_services.tracing.custom_headers | length > 0 %} + {% set _=kiali_vars['external_services']['tracing'].pop('custom_headers') %} + {% set kiali_vars=kiali_vars | combine({'external_services': {'tracing': {'custom_headers': current_cr.spec.external_services.tracing.custom_headers }}}, recursive=True) %} + {% endif %} + {# #} {{ kiali_vars }}