This guide covers authentication modes and deploying obs-mcp on Kubernetes/OpenShift clusters.
The --auth-mode flag controls how obs-mcp authenticates to Prometheus/Thanos:
| Mode | Token Source | Use Case |
|---|---|---|
kubeconfig |
Bearer token from ~/.kube/config |
Local development, accessing cluster via routes |
serviceaccount |
Pod's mounted token at /var/run/secrets/kubernetes.io/serviceaccount/token |
In-cluster deployment on OpenShift/Kubernetes |
header |
Forwarded from incoming MCP request's Authorization header |
Pass-through auth or when Prometheus doesn't require auth |
- Extracts the bearer token from your local kubeconfig
- Auto-discovers Prometheus/Thanos routes in OpenShift (only mode with auto-discovery)
- Requires token-based auth (
oc whoami -tmust return a token) - Best for: Local development when logged into a cluster
- Reads the service account token mounted inside the pod
- Requires explicit
PROMETHEUS_URL(no auto-discovery) - The ServiceAccount must have RBAC permissions to query the metrics endpoint
- Best for: In-cluster deployment on OpenShift with RBAC-protected Thanos/Prometheus
- Forwards the
Authorizationheader from incoming MCP client requests to Prometheus - If no header is provided, connects without authentication
- Requires explicit
PROMETHEUS_URL(no auto-discovery) - Best for: Pass-through auth scenarios or Prometheus without authentication (e.g., port-forwarded, local kube-prometheus)
Example manifests are provided in the manifests/ directory:
manifests/openshift/- Example for OpenShift with Thanos Queriermanifests/kubernetes/- Example for Kubernetes
These are reference examples that you'll need to customize for your environment.
When deploying in-cluster, you must configure:
PROMETHEUS_URL: Set the environment variable to your Prometheus/Thanos endpoint--auth-mode: Choose based on your Prometheus authentication requirements:serviceaccountif your Prometheus requires RBAC/token authheaderif your Prometheus doesn't require authentication
- ServiceAccount RBAC: If using
serviceaccountmode, ensure the ServiceAccount has permissions to query your metrics endpoint
The metrics backend URL is determined in the following order:
PROMETHEUS_URLenvironment variable (if set, always used)--metrics-backendflag route discovery (only inkubeconfigmode)- Default:
http://localhost:9090
Note
Auto-discovery only works in kubeconfig mode. For in-cluster deployments, you must set PROMETHEUS_URL explicitly.