Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions pkg/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"k8s.io/client-go/rest"

osmv1client "github.com/openshift/client-go/monitoring/clientset/versioned"
routeclient "github.com/openshift/client-go/route/clientset/versioned"
monitoringv1client "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
"github.com/sirupsen/logrus"
)
Expand All @@ -22,6 +23,8 @@ type client struct {
osmv1clientset *osmv1client.Clientset
config *rest.Config

prometheusAlerts *prometheusAlerts

prometheusRuleManager *prometheusRuleManager
namespaceManager *namespaceManager
}
Expand All @@ -42,6 +45,11 @@ func newClient(ctx context.Context, config *rest.Config) (Client, error) {
return nil, fmt.Errorf("failed to create osmv1 clientset: %w", err)
}

routeClientset, err := routeclient.NewForConfig(config)
if err != nil {
return nil, fmt.Errorf("failed to create route clientset: %w", err)
}

c := &client{
clientset: clientset,
monitoringv1clientset: monitoringv1clientset,
Expand All @@ -54,6 +62,8 @@ func newClient(ctx context.Context, config *rest.Config) (Client, error) {
return nil, fmt.Errorf("failed to create PrometheusRule manager: %w", err)
}

c.prometheusAlerts = newPrometheusAlerts(routeClientset, clientset.CoreV1(), config, c.prometheusRuleManager)

c.namespaceManager, err = newNamespaceManager(ctx, clientset)
if err != nil {
return nil, fmt.Errorf("failed to create namespace manager: %w", err)
Expand All @@ -70,6 +80,10 @@ func (c *client) TestConnection(_ context.Context) error {
return nil
}

func (c *client) PrometheusAlerts() PrometheusAlertsInterface {
return c.prometheusAlerts
}

func (c *client) PrometheusRules() PrometheusRuleInterface {
return c.prometheusRuleManager
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/k8s/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,33 @@ package k8s

const (
ClusterMonitoringNamespace = "openshift-monitoring"

PlatformRouteNamespace = "openshift-monitoring"
PlatformRouteName = "prometheus-k8s"
PlatformAlertmanagerRouteName = "alertmanager-main"
UserWorkloadRouteNamespace = "openshift-user-workload-monitoring"
UserWorkloadRouteName = "prometheus-user-workload"
UserWorkloadAlertmanagerRouteName = "alertmanager-user-workload"
PrometheusAlertsPath = "/v1/alerts"
PrometheusRulesPath = "/v1/rules"
AlertmanagerAlertsPath = "/api/v2/alerts"
UserWorkloadAlertmanagerPort = 9095
UserWorkloadPrometheusServiceName = "prometheus-user-workload-web"
UserWorkloadPrometheusPort = 9090

ThanosQuerierNamespace = "openshift-monitoring"
ThanosQuerierServiceName = "thanos-querier"
ThanosQuerierTenancyRulesPortName = "tenancy-rules"
DefaultThanosQuerierTenancyRulesPort = 9093
ThanosQuerierTenancyAlertsPath = "/api/v1/alerts"
ThanosQuerierTenancyRulesPath = "/api/v1/rules"
ServiceCAPath = "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"

AlertSourceLabel = "openshift_io_alert_source"
AlertSourcePlatform = "platform"
AlertSourceUser = "user"
AlertBackendLabel = "openshift_io_alert_backend"
AlertBackendAM = "alertmanager"
AlertBackendProm = "prometheus"
AlertBackendThanos = "thanos"
)
Loading