From 1fc5f7a9bdae118e6b6501c953ad7dc1a0affcb6 Mon Sep 17 00:00:00 2001
From: Michael Martin <michaelmartin@seed-innovations.com>
Date: Mon, 30 Sep 2024 17:29:15 +0000
Subject: [PATCH] dig some values in case the values are not set

---
 chart/templates/thanos/values.yaml | 68 ++++++++++++++++++++++++++----
 1 file changed, 60 insertions(+), 8 deletions(-)

diff --git a/chart/templates/thanos/values.yaml b/chart/templates/thanos/values.yaml
index 80fab40477..afa2835e61 100644
--- a/chart/templates/thanos/values.yaml
+++ b/chart/templates/thanos/values.yaml
@@ -40,6 +40,7 @@ istio:
   thanos:
     gateways:
     - istio-system/{{ default "public" .Values.addons.thanos.ingress.gateway }}
+
 {{- with .Values.addons.thanos.objectStorage }}
 {{- if and (eq $.Values.addons.thanos.strategy "scalable") (not (and .endpoint .region)) }}
 minio:
@@ -60,6 +61,11 @@ monitoring:
 
 storegateway:
   enabled: false
+  {{- if .Values.kiali.enabled }}
+  podLabels:
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+  {{- end }}
 
 query:
   dnsDiscovery:
@@ -78,15 +84,65 @@ query:
     {{- if (dig "values" "storegateway" "enabled" false .Values.addons.thanos) }}
     - dns+thanos-storegateway.thanos.svc.cluster.local:10901
     {{- end }}
-  {{- if .Values.addons.thanos.sso.enabled }}
-  {{- $thanosAuthserviceKey := (dig "selector" "key" "protect" .Values.addons.authservice.values) }}
-  {{- $thanosAuthserviceValue := (dig "selector" "value" "keycloak" .Values.addons.authservice.values) }}
+  {{- if or .Values.addons.thanos.sso.enabled .Values.kiali.enabled }}
   podLabels:
+    {{- if .Values.addons.thanos.sso.enabled }}
+    {{- $thanosAuthserviceKey := (dig "selector" "key" "protect" .Values.addons.authservice.values) }}
+    {{- $thanosAuthserviceValue := (dig "selector" "value" "keycloak" .Values.addons.authservice.values) }}
     {{ $thanosAuthserviceKey }}: {{ $thanosAuthserviceValue }}
+    {{- end }}
+    {{- if .Values.kiali.enabled }}
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+    {{- end }}
   {{- end }}
 
-{{- if not (.Values.addons.thanos.objectStorage.endpoint | empty) }}
+{{- if and (dig "queryFrontend" "enabled" true .Values.addons.thanos.values) $.Values.kiali.enabled }}
+queryFrontend:
+  podLabels:
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+{{- end }}
 
+{{- if and (dig "bucketweb" "enabled" false .Values.addons.thanos.values) .Values.kiali.enabled }}
+bucketweb:
+  podLabels:
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+{{- end }}
+
+{{- if and (dig "ruler" "enabled" false .Values.addons.thanos.values) .Values.kiali.enabled }}
+ruler:
+  podLabels:
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+{{- end }}
+
+{{- if and (dig "receive" "enabled" false .Values.addons.thanos.values) .Values.kiali.enabled }}
+receive:
+  podLabels:
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+{{- end }}
+
+{{- if and (dig "bucketweb" "enabled" false .Values.addons.thanos.values) .Values.kiali.enabled }}
+receiveDistributor:
+  podLabels:
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+{{- end }}
+
+{{- if or (dig "compactor" "enabled" false .Values.addons.thanos.values) (not (.Values.addons.thanos.objectStorage.endpoint | empty)) }}
+compactor:
+  enabled: true
+  {{- if .Values.kiali.enabled }}
+  podLabels:
+    {{- include "kialiAppLabel" . | nindent 4 }}
+    {{- include "kialiVersionLabel" . | nindent 4 }}
+  {{- end }}
+{{- end }}
+
+{{- if not (.Values.addons.thanos.objectStorage.endpoint | empty) }}
 objstoreConfig: |-
   type: s3
   config:
@@ -101,12 +157,8 @@ storegateway:
   useEndpointGroup: true
   endpoint: {{ .Values.addons.thanos.objectStorage.endpoint }}
 
-compactor:
-  enabled: true
-
 query:
   extraFlags:
     - "--endpoint=dns+monitoring-monitoring-kube-thanos-discovery.monitoring.svc.cluster.local:{{- dig "values" "query" "containerPorts" "grpc" 10901 .Values.addons.thanos }}"
-
 {{- end }}
 {{- end }}
-- 
GitLab