Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions cmd/bridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func main() {
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.")
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.")

fK8sAuth := fs.String("k8s-auth", "service-account", "service-account | bearer-token | oidc | openshift")
fK8sAuthBearerToken := fs.String("k8s-auth-bearer-token", "", "Authorization token to send with proxied Kubernetes API requests.")
Expand Down Expand Up @@ -146,18 +147,6 @@ func main() {
documentationBaseURL = bridge.ValidateFlagIsURL("documentation-base-url", *fDocumentationBaseURL)
}

offClusterPrometheusURL := &url.URL{}
if *fK8sModeOffClusterPrometheus != "" && *fK8sMode == "off-cluster" {
offClusterPrometheusURL = bridge.ValidateFlagIsURL("k8s-mode-off-cluster-prometheus", *fK8sModeOffClusterPrometheus)
offClusterPrometheusURL.Path = "/api"
}

offClusterAlertManagerURL := &url.URL{}
if *fK8sModeOffClusterAlertmanager != "" && *fK8sMode == "off-cluster" {
offClusterAlertManagerURL = bridge.ValidateFlagIsURL("k8s-mode-off-cluster-alertmanager", *fK8sModeOffClusterAlertmanager)
offClusterAlertManagerURL.Path = "/api"
}

branding := *fBranding
if branding == "origin" {
branding = "okd"
Expand Down Expand Up @@ -311,7 +300,9 @@ func main() {
Endpoint: k8sEndpoint,
}

if offClusterPrometheusURL.String() != "" {
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"},
Expand All @@ -324,14 +315,26 @@ func main() {
}
}

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

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

default:
bridge.FlagFatalf("k8s-mode", "must be one of: in-cluster, off-cluster")
}
Expand Down