Skip to content

Commit f7a22f7

Browse files
authored
Allow using service account token for Prometheus/Alertmanager auth (even not in openshift) (#1968)
1 parent 453fb97 commit f7a22f7

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

docs/configuration/metric-providers-external.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ Authentication
5555
prometheus_auth: "Bearer YOUR_TOKEN_HERE"
5656
alertmanager_auth: "Bearer YOUR_TOKEN_HERE"
5757
58+
On some clusters, the pod service account token is used for Prometheus/Alertmanager authentication.
59+
To use this token add the following env var to the ``runner``:
60+
61+
.. code-block:: yaml
62+
63+
runner:
64+
additional_env_vars:
65+
- name: PROMETHEUS_CLUSTER_TOKEN_AUTH
66+
value: "true"
67+
68+
5869
**Basic Authentication**:
5970

6071
.. code-block:: yaml

docs/configuration/metric-providers-in-cluster.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ If Prometheus and/or AlertManager require authentication, add the following:
9292
9393
These settings may be configured independently.
9494

95+
On some clusters, the pod service account token is used for Prometheus/Alertmanager authentication.
96+
To use this token add the following env var to the ``runner``:
97+
98+
.. code-block:: yaml
99+
100+
runner:
101+
additional_env_vars:
102+
- name: PROMETHEUS_CLUSTER_TOKEN_AUTH
103+
value: "true"
104+
95105
SSL Verification
96106
^^^^^^^^^^^^^^^^
97107

src/robusta/core/model/env_vars.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def load_bool(env_var, default: bool):
114114
CLUSTER_DOMAIN = os.environ.get("CLUSTER_DOMAIN", "cluster.local")
115115

116116
IS_OPENSHIFT = load_bool("IS_OPENSHIFT", False)
117+
PROMETHEUS_CLUSTER_TOKEN_AUTH = load_bool("PROMETHEUS_CLUSTER_TOKEN_AUTH", False)
118+
117119
OPENSHIFT_GROUPS = load_bool("OPENSHIFT_GROUPS", False)
118120

119121
ENABLE_GRAPH_BLOCK = load_bool("ENABLE_GRAPH_BLOCK", True)

src/robusta/integrations/openshift/token.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from typing import Optional
22

3-
from robusta.core.model.env_vars import IS_OPENSHIFT
3+
from robusta.core.model.env_vars import IS_OPENSHIFT, PROMETHEUS_CLUSTER_TOKEN_AUTH
44

55
# NOTE: This one will be mounted if openshift is enabled in values.yaml
66
TOKEN_LOCATION = '/var/run/secrets/kubernetes.io/serviceaccount/token'
77

88

99
def load_token() -> Optional[str]:
10-
if not IS_OPENSHIFT:
10+
if not (IS_OPENSHIFT or PROMETHEUS_CLUSTER_TOKEN_AUTH):
1111
return None
1212

1313
try:

0 commit comments

Comments
 (0)