Skip to content

Commit

Permalink
try to auto-discover the istio configmap
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazzitelli committed Jul 24, 2024
1 parent 5d242bb commit 6774b3f
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,29 @@
- kiali_vars.deployment.cluster_wide_access == False
- kiali_vars.deployment.discovery_selectors.default is defined

### TODO
- name: Determine Istio ConfigMap name if we need to read it to find the discovery selectors
- name: Find the Istio ConfigMap if we need to read it to find the discovery selectors
vars:
all_configmaps: "{{ query(k8s_plugin, kind='ConfigMap', namespace=kiali_vars.istio_namespace, errors='warn') }}"
set_fact:
istio_configmap_name: "istio"
istio_configmap: "{{ item }}"
loop: "{{ all_configmaps }}"
when:
- kiali_vars.deployment.cluster_wide_access == False
- discovery_selectors is not defined
- item.data is defined
- item.data.mesh is defined

- name: Get Istio discovery selectors if they are defined and if we need them
vars:
istio_configmap: "{{ lookup(k8s_plugin, kind='ConfigMap', namespace=kiali_vars.istio_namespace, resource_name=istio_configmap_name, errors='warn') | from_yaml }}"
istio_configmap_data_mesh: "{{ istio_configmap.data.mesh | default({}) | from_yaml }}"
istio_discovery_selectors: "{{ (istio_configmap.data.mesh | from_yaml).discoverySelectors | default ([]) }}"
set_fact:
discovery_selectors: "{{ istio_configmap_data_mesh.discoverySelectors }}"
discovery_selectors: "{{ istio_discovery_selectors }}"
using_istio_discovery_selectors: true
when:
- kiali_vars.deployment.cluster_wide_access == False
- discovery_selectors is not defined
- istio_configmap_name is defined
- istio_configmap.data is defined
- istio_configmap.data.mesh is defined
- istio_configmap_data_mesh.discoverySelectors is defined
- istio_configmap is defined
- istio_discovery_selectors | length > 0

- name: If cluster wide access is disabled and no discovery selectors are found, warn the user that this is probably not what they want
debug:
Expand All @@ -47,6 +49,12 @@
- kiali_vars.discovery_selectors.default is not defined
- discovery_selectors is not defined

- debug:
msg: "Using discovery selectors found in Istio ConfigMap [{{ istio_configmap.metadata.name }}] from namespace [{{ kiali_vars.istio_namespace }}]."
when:
- using_istio_discovery_selectors is defined
- using_istio_discovery_selectors == True

- name: Find namespaces selected by the discovery selectors
set_fact:
discovery_selector_namespaces_raw: "{{ (discovery_selector_namespaces_raw|default([]) + query(k8s_plugin, kind='Namespace', label_selector=(item|join(',')))) | unique }}"
Expand Down

0 comments on commit 6774b3f

Please sign in to comment.