From ea12b9df687833228fc98eecbb1f25974a8de516 Mon Sep 17 00:00:00 2001 From: John Mazzitelli Date: Fri, 27 Sep 2024 12:01:46 -0400 Subject: [PATCH] add new extensions configuration (#787) * add new extensions configuration * Apply suggestions from code review Co-authored-by: Jay Shaughnessy --------- Co-authored-by: Jay Shaughnessy --- crd-docs/cr/kiali.io_v1alpha1_kiali.yaml | 5 +++++ crd-docs/crd/kiali.io_kialis.yaml | 14 ++++++++++++++ molecule/config-values-test/converge.yml | 20 ++++++++++++++++++++ roles/default/kiali-deploy/defaults/main.yml | 2 ++ roles/default/kiali-deploy/vars/main.yml | 7 +++++++ 5 files changed, 48 insertions(+) diff --git a/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml b/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml index 8488b2a6..ce686eb9 100644 --- a/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml +++ b/crd-docs/cr/kiali.io_v1alpha1_kiali.yaml @@ -235,6 +235,11 @@ spec: version_label: "" view_only_mode: false + # default: extensions is an empty list + extensions: + - enabled: true + name: "skupper" + external_services: custom_dashboards: discovery_auto_threshold: 10 diff --git a/crd-docs/crd/kiali.io_kialis.yaml b/crd-docs/crd/kiali.io_kialis.yaml index 5a7d0418..73c36948 100644 --- a/crd-docs/crd/kiali.io_kialis.yaml +++ b/crd-docs/crd/kiali.io_kialis.yaml @@ -632,6 +632,20 @@ spec: description: "When true, Kiali will be in 'view only' mode, allowing the user to view and retrieve management and monitoring data for the service mesh, but not allow the user to modify the service mesh." type: boolean + extensions: + description: | + Defines third-party extensions whose metrics can be integrated into the Kiali traffic graph. + type: array + items: + type: object + properties: + enabled: + description: Determines if the Kiali traffic graph should incorporate the extension's metrics. + type: boolean + name: + description: The name that is used to identify the metric time series for the extension. + type: string + external_services: description: | These external service configuration settings define how to connect to the external services diff --git a/molecule/config-values-test/converge.yml b/molecule/config-values-test/converge.yml index 1a59a2fb..d2d02148 100644 --- a/molecule/config-values-test/converge.yml +++ b/molecule/config-values-test/converge.yml @@ -93,6 +93,11 @@ - kiali_pod_spec.dnsPolicy == "ClusterFirst" - kiali_pod_spec.dnsConfig is not defined + - name: Test the default extensions list is empty + assert: + that: + - kiali_configmap.extensions | length == 0 + # This test will change some config settings to make sure things work like we expect. # We will add additional tasks and asserts in the future to test other config changes. # We load in the current kiali CR and then alter it with new config and deploy that new CR. @@ -204,6 +209,14 @@ set_fact: current_kiali_cr: "{{ current_kiali_cr | combine({'spec': {'deployment': {'dns': dns_settings}}}, recursive=True) }}" + - name: Add an extension + vars: + extensions: + - name: "skupper" + enabled: false + set_fact: + current_kiali_cr: "{{ current_kiali_cr | combine({'spec': {'extensions': extensions}}, recursive=True) }}" + - name: The new Kiali CR to be tested debug: msg: "{{ current_kiali_cr }}" @@ -358,3 +371,10 @@ - kiali_pod_spec.dnsPolicy == "Default" - kiali_pod_spec.dnsConfig.options[0].name == "ndots" - kiali_pod_spec.dnsConfig.options[0].value == "1" + + - name: Test the extensions settings + assert: + that: + - kiali_configmap.extensions | length == 1 + - kiali_configmap.extensions[0].name == "skupper" + - kiali_configmap.extensions[0].enabled == False diff --git a/roles/default/kiali-deploy/defaults/main.yml b/roles/default/kiali-deploy/defaults/main.yml index ac0b3b00..7dc1540e 100644 --- a/roles/default/kiali-deploy/defaults/main.yml +++ b/roles/default/kiali-deploy/defaults/main.yml @@ -96,6 +96,8 @@ kiali_defaults: version_label: "" view_only_mode: false + extensions: [] + external_services: custom_dashboards: discovery_auto_threshold: 10 diff --git a/roles/default/kiali-deploy/vars/main.yml b/roles/default/kiali-deploy/vars/main.yml index 5a567c9a..55358361 100644 --- a/roles/default/kiali-deploy/vars/main.yml +++ b/roles/default/kiali-deploy/vars/main.yml @@ -52,6 +52,13 @@ kiali_vars: {{ kiali_defaults.deployment }} {%- endif -%} + extensions: | + {%- if extensions is defined and extensions is iterable -%} + {{ extensions }} + {%- else -%} + {{ kiali_defaults.extensions }} + {%- endif -%} + external_services: | {%- if external_services is defined and external_services is iterable -%} {{ kiali_defaults.external_services | combine((external_services | stripnone), recursive=True) }}