Skip to content

Commit

Permalink
*: remove all references to Prometheus
Browse files Browse the repository at this point in the history
The console backend doesn't need to access the prometheus-k8s service
anymore. All requests are done against the Thanos querier service
instead.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
  • Loading branch information
simonpasquier committed Jul 20, 2020
1 parent 9f1cd49 commit 0bd839d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 25 deletions.
20 changes: 1 addition & 19 deletions cmd/bridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ const (
k8sInClusterCA = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
k8sInClusterBearerToken = "/var/run/secrets/kubernetes.io/serviceaccount/token"

// Well-known location of the cluster monitoring (not user workload monitoring) Prometheus service for OpenShift.
// This is only accessible in-cluster. This is used for non-tenant global (alerting) rules requests.
openshiftPrometheusHost = "prometheus-k8s.openshift-monitoring.svc:9091"

// Well-known location of the tenant aware Thanos service for OpenShift exposing the query and query_range endpoints. This is only accessible in-cluster.
// Thanos proxies requests to both cluster monitoring and user workload monitoring prometheus instances.
openshiftThanosTenancyHost = "thanos-querier.openshift-monitoring.svc:9092"
Expand Down Expand Up @@ -84,7 +80,6 @@ func main() {
fK8sMode := fs.String("k8s-mode", "in-cluster", "in-cluster | off-cluster")
fK8sModeOffClusterEndpoint := fs.String("k8s-mode-off-cluster-endpoint", "", "URL of the Kubernetes API server.")
fK8sModeOffClusterSkipVerifyTLS := fs.Bool("k8s-mode-off-cluster-skip-verify-tls", false, "DEV ONLY. When true, skip verification of certs presented by k8s API server.")
fK8sModeOffClusterPrometheus := fs.String("k8s-mode-off-cluster-prometheus", "", "DEV ONLY. URL of the cluster's Prometheus server.")
fK8sModeOffClusterThanos := fs.String("k8s-mode-off-cluster-thanos", "", "DEV ONLY. URL of the cluster's Thanos server.")
fK8sModeOffClusterAlertmanager := fs.String("k8s-mode-off-cluster-alertmanager", "", "DEV ONLY. URL of the cluster's AlertManager server.")
fK8sModeOffClusterMetering := fs.String("k8s-mode-off-cluster-metering", "", "DEV ONLY. URL of the cluster's metering server.")
Expand Down Expand Up @@ -323,11 +318,6 @@ func main() {
RootCAs: serviceProxyRootCAs,
CipherSuites: crypto.DefaultCiphers(),
}
srv.PrometheusProxyConfig = &proxy.Config{
TLSClientConfig: serviceProxyTLSConfig,
HeaderBlacklist: []string{"Cookie", "X-CSRFToken"},
Endpoint: &url.URL{Scheme: "https", Host: openshiftPrometheusHost, Path: "/api"},
}
srv.ThanosProxyConfig = &proxy.Config{
TLSClientConfig: serviceProxyTLSConfig,
HeaderBlacklist: []string{"Cookie", "X-CSRFToken"},
Expand Down Expand Up @@ -368,15 +358,7 @@ func main() {
Endpoint: k8sEndpoint,
}

if *fK8sModeOffClusterPrometheus != "" {
offClusterPrometheusURL := bridge.ValidateFlagIsURL("k8s-mode-off-cluster-prometheus", *fK8sModeOffClusterPrometheus)
offClusterPrometheusURL.Path = "/api"
srv.PrometheusProxyConfig = &proxy.Config{
TLSClientConfig: serviceProxyTLSConfig,
HeaderBlacklist: []string{"Cookie", "X-CSRFToken"},
Endpoint: offClusterPrometheusURL,
}

if *fK8sModeOffClusterThanos != "" {
offClusterThanosURL := bridge.ValidateFlagIsURL("k8s-mode-off-cluster-thanos", *fK8sModeOffClusterThanos)
offClusterThanosURL.Path = "/api"
srv.ThanosTenancyProxyConfig = &proxy.Config{
Expand Down
3 changes: 0 additions & 3 deletions contrib/oc-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS
BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.thanosPublicURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS

BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.prometheusPublicURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_PROMETHEUS

BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.alertmanagerPublicURL}')
export BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER

Expand Down
1 change: 0 additions & 1 deletion examples/run-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ set -exuo pipefail
--user-auth-oidc-client-id=console-oauth-client \
--user-auth-oidc-client-secret-file=examples/console-client-secret \
--user-auth-oidc-ca-file=examples/ca.crt \
--k8s-mode-off-cluster-prometheus="$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.prometheusPublicURL}')" \
--k8s-mode-off-cluster-alertmanager="$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.alertmanagerPublicURL}')" \
--k8s-mode-off-cluster-thanos="$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.thanosPublicURL}')"
3 changes: 1 addition & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ type Server struct {
DexClient api.DexClient
// A client with the correct TLS setup for communicating with the API server.
K8sClient *http.Client
PrometheusProxyConfig *proxy.Config
ThanosProxyConfig *proxy.Config
ThanosTenancyProxyConfig *proxy.Config
ThanosTenancyProxyForRulesConfig *proxy.Config
Expand All @@ -130,7 +129,7 @@ func (s *Server) authDisabled() bool {
}

func (s *Server) prometheusProxyEnabled() bool {
return s.PrometheusProxyConfig != nil && s.ThanosTenancyProxyConfig != nil && s.ThanosTenancyProxyForRulesConfig != nil
return s.ThanosTenancyProxyConfig != nil && s.ThanosTenancyProxyForRulesConfig != nil
}

func (s *Server) alertManagerProxyEnabled() bool {
Expand Down

0 comments on commit 0bd839d

Please sign in to comment.