From 8850530861e6c231ba470f5c518481d221958030 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sat, 13 Dec 2025 08:49:51 -0600 Subject: [PATCH] Set cluster name to loki --- README.md | 22 ++++++++++++++++++++ k8s/loki/templates/podlogs.yaml | 2 +- k8s/loki/values.yaml | 2 ++ k8s/monitoring/templates/loki-dashboard.yaml | 4 ++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1661436..1e485b4 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,28 @@ This README would normally document whatever steps are necessary to get your app ``` This ensures that `k8s/crds/all-crds.yaml` is automatically updated whenever you modify the monitoring Helm chart. +### Monitoring Chart Patch (Critical) + +The included chart `k8s/monitoring/charts/kube-prometheus-stack-75.12.0.tgz` is **MANUALLY PATCHED**. + +**Why?** +The upstream chart (v65.x+) introduced a field `trackTimestampsStaleness` in the `ServiceMonitor` CRD. Our cluster is running an older version of the Prometheus Operator/CRDs that does not support this field. The upstream chart renders this field unconditionally in some templates (specifically `kubelet`), causing ArgoCD sync to fail with a schema validation error ("field not declared in schema"). + +**How was it patched?** +1. Unpacked the official `kube-prometheus-stack-75.12.0.tgz`. +2. Modified `templates/exporters/kubelet/servicemonitor.yaml`. +3. Wrapped `trackTimestampsStaleness` in a conditional block: + ```yaml + {{- if .Values.kubelet.serviceMonitor.trackTimestampsStaleness }} + trackTimestampsStaleness: {{ .Values.kubelet.serviceMonitor.trackTimestampsStaleness }} + {{- end }} + ``` +4. Repackaged the chart using `tar -czf`. +5. Force added to git (`git add -f`) because `charts/*.tgz` is ignored. + +**When to delete?** +You can revert to the official upstream chart once the Prometheus Operator CRDs on the cluster are upgraded to a version that includes `trackTimestampsStaleness` in the `ServiceMonitor` schema (likely Prometheus Operator >= v0.68.0 or similar). + ### How do I get set up? ### * Summary of set up diff --git a/k8s/loki/templates/podlogs.yaml b/k8s/loki/templates/podlogs.yaml index 54cbdd7..05bacdd 100644 --- a/k8s/loki/templates/podlogs.yaml +++ b/k8s/loki/templates/podlogs.yaml @@ -40,7 +40,7 @@ spec: - __meta_kubernetes_namespace targetLabel: namespace - action: replace - replacement: loki + replacement: {{ .Values.clusterName | default "loki" }} targetLabel: cluster pipelineStages: - cri: {} diff --git a/k8s/loki/values.yaml b/k8s/loki/values.yaml index 1919b9d..7cfecc6 100644 --- a/k8s/loki/values.yaml +++ b/k8s/loki/values.yaml @@ -1,4 +1,6 @@ loki: + # Default cluster name if not overridden + clusterName: default loki: config: | auth_enabled: false diff --git a/k8s/monitoring/templates/loki-dashboard.yaml b/k8s/monitoring/templates/loki-dashboard.yaml index 317b40d..81f0148 100644 --- a/k8s/monitoring/templates/loki-dashboard.yaml +++ b/k8s/monitoring/templates/loki-dashboard.yaml @@ -881,8 +881,8 @@ data: { "allValue": ".+", "current": { - "text": "prod", - "value": "prod" + "text": "default", + "value": "default" }, "datasource": "$logs", "hide": 0,