From 895db2a2725020dff8cf5e76fc26165db58124f6 Mon Sep 17 00:00:00 2001
From: Brad Ison <bison@xvdf.io>
Date: Mon, 15 Jan 2024 10:16:17 +0100
Subject: [PATCH] jsonnet/components/prometheus: Fix thanos-sidecar metrics
 access (#2330)

When enabled, the thanos-sidecar opens an HTTP listener on port 10902,
which what's used to scrape metrics.  This port wasn't being added to
the Prometheus Service, so wasn't added to the NetworkPolicy causing
scraping to fail from Prometheus instances other than the local one.

This adds the port to the Service and NetworkPolicy.

Fixes: #2006
---
 jsonnet/kube-prometheus/components/prometheus.libsonnet | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/jsonnet/kube-prometheus/components/prometheus.libsonnet b/jsonnet/kube-prometheus/components/prometheus.libsonnet
index 3b7f5221..72d5019c 100644
--- a/jsonnet/kube-prometheus/components/prometheus.libsonnet
+++ b/jsonnet/kube-prometheus/components/prometheus.libsonnet
@@ -175,7 +175,10 @@ function(params) {
              ] +
              (
                if p._config.thanos != null then
-                 [{ name: 'grpc', port: 10901, targetPort: 10901 }]
+                 [
+                   { name: 'grpc', port: 10901, targetPort: 10901 },
+                   { name: 'http', port: 10902, targetPort: 10902 },
+                 ]
                else []
              ),
       selector: p._config.selectorLabels,
-- 
GitLab