Skip to content

Commit

Permalink
Enable monitoring of olm and marketplace operators
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan committed Jul 5, 2022
1 parent 5c214d5 commit 5a0cfd2
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 5 deletions.
4 changes: 4 additions & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ parameters:
defaultInstallPlanApproval: Automatic
defaultSourceNamespace: openshift-marketplace

monitoring:
enabled: true
instance: null

openshift_operators:
defaultSource: certified-operators

Expand Down
2 changes: 1 addition & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ local namespace = operatorlib.validateInstance(params.namespace);
},
},
],
}
} + (import 'monitoring.libsonnet')
112 changes: 112 additions & 0 deletions component/monitoring.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
local cm = import 'lib/cert-manager.libsonnet';
local com = import 'lib/commodore.libjsonnet';
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 catalogOperatorMonitor = prom.ServiceMonitor('openshift-marketplace-operator') {
metadata+: {
namespace: nsName,
},
spec+: {
endpoints: [
{
bearerTokenFile: '/var/run/secrets/kubernetes.io/serviceaccount/token',
interval: '30s',
metricRelabelings: [
{
action: 'drop',
regex: 'etcd_(debugging|disk|request|server).*',
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',
},
},
},
};

local olmOperatorMonitor = prom.ServiceMonitor('openshift-olm-operator') {
metadata+: {
namespace: nsName,
},
spec+: {
endpoints: [
{
bearerTokenFile: '/var/run/secrets/kubernetes.io/serviceaccount/token',
interval: '30s',
metricRelabelings: [
{
action: 'drop',
regex: 'etcd_(debugging|disk|request|server).*',
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',
},
},
},
};

if params.monitoring.enabled && std.member(inv.applications, 'prometheus') then
{
monitoring: [
prom.RegisterNamespace(
kube.Namespace(nsName),
instance=promInstance
),
catalogOperatorMonitor,
olmOperatorMonitor,
],
}
else
std.trace(
'Monitoring disabled or component `prometheus` not present, '
+ 'not deploying ServiceMonitors',
{}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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__
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-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__
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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__
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-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__
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
13 changes: 11 additions & 2 deletions tests/openshift-operators-redhat.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Overwrite parameters here
applications:
- prometheus

# parameters: {...}
parameters:
kapitan:
dependencies:
- type: https
source: https://raw.githubusercontent.com/projectsyn/component-prometheus/master/lib/prometheus.libsonnet
output_path: vendor/lib/prometheus.libsonnet

prometheus:
defaultInstance: infra
13 changes: 11 additions & 2 deletions tests/openshift-operators.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Overwrite parameters here
applications:
- prometheus

# parameters: {...}
parameters:
kapitan:
dependencies:
- type: https
source: https://raw.githubusercontent.com/projectsyn/component-prometheus/master/lib/prometheus.libsonnet
output_path: vendor/lib/prometheus.libsonnet

prometheus:
defaultInstance: infra

0 comments on commit 5a0cfd2

Please sign in to comment.