From be8fd8778c5a3b63b39af07bae96d6f1c4510504 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Tue, 7 Mar 2023 15:43:44 +0100 Subject: [PATCH] Remove support for component-prometheus based monitoring We've ended up never using component-prometheus on OpenShift 4, and have changed our strategy to build OpenShift 4 monitoring on the cluster-monitoring and user-workload-monitoring stacks provided by OpenShift 4. Therefore the logic to enable a component-prometheus monitoring stack to scrape metrics from namespaces/workloads managed through this component is no longer necessary. This commit completely removes support for component-prometheus in this component. --- class/defaults.yml | 4 - component/main.jsonnet | 2 +- component/monitoring.libsonnet | 118 ------------------ .../ROOT/pages/references/parameters.adoc | 28 ----- jsonnetfile.json | 14 --- .../openshift4-operators/monitoring.yaml | 107 ---------------- .../openshift4-operators/monitoring.yaml | 107 ---------------- .../openshift4-operators/monitoring.yaml | 107 ---------------- 8 files changed, 1 insertion(+), 486 deletions(-) delete mode 100644 component/monitoring.libsonnet delete mode 100644 jsonnetfile.json delete mode 100644 tests/golden/openshift-operators-custom/openshift-operators-custom/openshift4-operators/monitoring.yaml delete mode 100644 tests/golden/openshift-operators-redhat/openshift-operators-redhat/openshift4-operators/monitoring.yaml delete mode 100644 tests/golden/openshift-operators/openshift-operators/openshift4-operators/monitoring.yaml diff --git a/class/defaults.yml b/class/defaults.yml index 4176156..8b0e066 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -9,10 +9,6 @@ parameters: defaultSourceNamespace: openshift-marketplace useCustomNamespace: false - monitoring: - enabled: true - instance: null - openshift_operators: defaultSource: certified-operators diff --git a/component/main.jsonnet b/component/main.jsonnet index 94d8903..83ff085 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -30,4 +30,4 @@ local namespace = operatorlib.validateInstance(params.namespace); }, }, ], -} + (import 'monitoring.libsonnet') +} diff --git a/component/monitoring.libsonnet b/component/monitoring.libsonnet deleted file mode 100644 index b95e5a3..0000000 --- a/component/monitoring.libsonnet +++ /dev/null @@ -1,118 +0,0 @@ -/* -This file adds ServiceMonitors in combination with the Prometheus component. - -Warning: The operators monitored are instance independent, - everything in this file must be instance independent. -*/ - -local kap = import 'lib/kapitan.libjsonnet'; -local kube = import 'lib/kube.libjsonnet'; -local prom = import 'lib/prometheus.libsonnet'; -local inv = kap.inventory(); -// The hiera parameters for the component -local params = inv.parameters.openshift4_operators; - -local nsName = 'syn-monitoring-openshift4-operators'; - -local promInstance = - if params.monitoring.instance != null then - params.monitoring.instance - else - inv.parameters.prometheus.defaultInstance; - -local endpoint = function(serverName) - prom.ServiceMonitorHttpsEndpoint(serverName) { - port: 'https-metrics', - metricRelabelings: [ - { - action: 'drop', - regex: 'etcd_(debugging|disk|request|server).*', - sourceLabels: [ - '__name__', - ], - }, - prom.DropRuntimeMetrics, - ], - }; - -local marketplaceOperatorMonitor = prom.ServiceMonitor('openshift-marketplace-operator') { - metadata+: { - namespace: nsName, - }, - spec+: { - endpoints: [ - endpoint('marketplace-operator-metrics.openshift-marketplace.svc'), - ], - namespaceSelector: { - matchNames: [ - 'openshift-marketplace', - ], - }, - selector: { - matchLabels: { - name: 'marketplace-operator', - }, - }, - }, -}; - -local olmOperatorMonitor = prom.ServiceMonitor('openshift-olm-operator') { - metadata+: { - namespace: nsName, - }, - spec+: { - endpoints: [ - endpoint('olm-operator-metrics.openshift-operator-lifecycle-manager.svc'), - ], - namespaceSelector: { - matchNames: [ - 'openshift-operator-lifecycle-manager', - ], - }, - selector: { - matchLabels: { - app: 'olm-operator', - }, - }, - }, -}; - -local catalogOperatorMonitor = prom.ServiceMonitor('openshift-catalog-operator') { - metadata+: { - namespace: nsName, - }, - spec+: { - endpoints: [ - endpoint('catalog-operator-metrics.openshift-operator-lifecycle-manager.svc'), - ], - namespaceSelector: { - matchNames: [ - 'openshift-operator-lifecycle-manager', - ], - }, - selector: { - matchLabels: { - app: 'catalog-operator', - }, - }, - }, -}; - -if params.monitoring.enabled && std.member(inv.applications, 'prometheus') then - { - monitoring: [ - prom.RegisterNamespace( - kube.Namespace(nsName), - instance=promInstance - ), - marketplaceOperatorMonitor, - catalogOperatorMonitor, - olmOperatorMonitor, - ], - } -else - std.trace( - 'Monitoring disabled or component `prometheus` not present, ' - + 'not deploying ServiceMonitors', - {} - ) diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index 2eda811..69a9b30 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -71,31 +71,3 @@ default:: `false` Whether to allow non-standard namespace names for the OperatorGroup. If this parameter is set to `true`, the component will allow using namespace names other than `openshift-operators` and `openshift-operators-redhat`. - -== `monitoring` - -This parameter allows users to enable the component's monitoring configuration. -Currently the component has support for deploying custom `ServiceMonitors` on clusters which use component `prometheus` to manage a custom monitoring stack. - -[WARNING] -The monitoring configuration is instance independent. It must not be changed between instances of this component. - -=== `enabled` - -[horizontal] -type:: boolean -default:: `true` - -Whether to deploy monitoring configurations. -If this parameter is set to `true`, the component will check whether component `prometheus` is present on the cluster. -If the component is missing, no configurations will be deployed regardless of the value of this parameter. - -=== `instance` - -[horizontal] -type:: string -default:: `null` - -This parameter can be used to indicate which custom Prometheus instance should pick up the configurations managed by the component. - -If the parameter is set to the empty string, the default instance configured for component `prometheus` will be used. diff --git a/jsonnetfile.json b/jsonnetfile.json deleted file mode 100644 index b3abc0c..0000000 --- a/jsonnetfile.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "version": 1, - "dependencies": [ - { - "source": { - "git": { - "remote": "https://github.com/bitnami-labs/kube-libsonnet" - } - }, - "version": "v1.19.0" - } - ], - "legacyImports": true -} diff --git a/tests/golden/openshift-operators-custom/openshift-operators-custom/openshift4-operators/monitoring.yaml b/tests/golden/openshift-operators-custom/openshift-operators-custom/openshift4-operators/monitoring.yaml deleted file mode 100644 index c23b865..0000000 --- a/tests/golden/openshift-operators-custom/openshift-operators-custom/openshift4-operators/monitoring.yaml +++ /dev/null @@ -1,107 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - annotations: {} - labels: - monitoring.syn.tools/infra: 'true' - name: syn-monitoring-openshift4-operators - name: syn-monitoring-openshift4-operators ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-marketplace-operator - name: openshift-marketplace-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: marketplace-operator-metrics.openshift-marketplace.svc - namespaceSelector: - matchNames: - - openshift-marketplace - selector: - matchLabels: - name: marketplace-operator ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-catalog-operator - name: openshift-catalog-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: catalog-operator-metrics.openshift-operator-lifecycle-manager.svc - namespaceSelector: - matchNames: - - openshift-operator-lifecycle-manager - selector: - matchLabels: - app: catalog-operator ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-olm-operator - name: openshift-olm-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: olm-operator-metrics.openshift-operator-lifecycle-manager.svc - namespaceSelector: - matchNames: - - openshift-operator-lifecycle-manager - selector: - matchLabels: - app: olm-operator diff --git a/tests/golden/openshift-operators-redhat/openshift-operators-redhat/openshift4-operators/monitoring.yaml b/tests/golden/openshift-operators-redhat/openshift-operators-redhat/openshift4-operators/monitoring.yaml deleted file mode 100644 index c23b865..0000000 --- a/tests/golden/openshift-operators-redhat/openshift-operators-redhat/openshift4-operators/monitoring.yaml +++ /dev/null @@ -1,107 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - annotations: {} - labels: - monitoring.syn.tools/infra: 'true' - name: syn-monitoring-openshift4-operators - name: syn-monitoring-openshift4-operators ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-marketplace-operator - name: openshift-marketplace-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: marketplace-operator-metrics.openshift-marketplace.svc - namespaceSelector: - matchNames: - - openshift-marketplace - selector: - matchLabels: - name: marketplace-operator ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-catalog-operator - name: openshift-catalog-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: catalog-operator-metrics.openshift-operator-lifecycle-manager.svc - namespaceSelector: - matchNames: - - openshift-operator-lifecycle-manager - selector: - matchLabels: - app: catalog-operator ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-olm-operator - name: openshift-olm-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: olm-operator-metrics.openshift-operator-lifecycle-manager.svc - namespaceSelector: - matchNames: - - openshift-operator-lifecycle-manager - selector: - matchLabels: - app: olm-operator diff --git a/tests/golden/openshift-operators/openshift-operators/openshift4-operators/monitoring.yaml b/tests/golden/openshift-operators/openshift-operators/openshift4-operators/monitoring.yaml deleted file mode 100644 index c23b865..0000000 --- a/tests/golden/openshift-operators/openshift-operators/openshift4-operators/monitoring.yaml +++ /dev/null @@ -1,107 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - annotations: {} - labels: - monitoring.syn.tools/infra: 'true' - name: syn-monitoring-openshift4-operators - name: syn-monitoring-openshift4-operators ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-marketplace-operator - name: openshift-marketplace-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: marketplace-operator-metrics.openshift-marketplace.svc - namespaceSelector: - matchNames: - - openshift-marketplace - selector: - matchLabels: - name: marketplace-operator ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-catalog-operator - name: openshift-catalog-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: catalog-operator-metrics.openshift-operator-lifecycle-manager.svc - namespaceSelector: - matchNames: - - openshift-operator-lifecycle-manager - selector: - matchLabels: - app: catalog-operator ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - annotations: {} - labels: - name: openshift-olm-operator - name: openshift-olm-operator - namespace: syn-monitoring-openshift4-operators -spec: - endpoints: - - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - interval: 30s - metricRelabelings: - - action: drop - regex: etcd_(debugging|disk|request|server).* - sourceLabels: - - __name__ - - action: drop - regex: (go_.*|process_.*|promhttp_.*) - sourceLabels: - - __name__ - port: https-metrics - scheme: https - tlsConfig: - caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - serverName: olm-operator-metrics.openshift-operator-lifecycle-manager.svc - namespaceSelector: - matchNames: - - openshift-operator-lifecycle-manager - selector: - matchLabels: - app: olm-operator