From 519bfa0e6ecd57059be6ab9c5aca19cf32dcdd80 Mon Sep 17 00:00:00 2001 From: Gabriel Mainberger Date: Fri, 2 Jun 2023 14:05:04 +0200 Subject: [PATCH] Change monitoring labels for Prometheus SYNMonitoring is no longer relevant and has been removed. Support for component-prometheus and OpenShift 4 has been added. --- component/main.jsonnet | 22 ++++++++++++++----- .../builtin/builtin/builtin/00_namespace.yaml | 1 - 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/component/main.jsonnet b/component/main.jsonnet index 1b81e1de..42acd384 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -3,16 +3,26 @@ local k8up = import 'lib/backup-k8up.libjsonnet'; local com = import 'lib/commodore.libjsonnet'; local kap = import 'lib/kapitan.libjsonnet'; local kube = import 'lib/kube.libjsonnet'; +local prometheus = import 'lib/prometheus.libjsonnet'; local inv = kap.inventory(); // The hiera parameters for the component local params = inv.parameters.keycloak; -local namespace = kube.Namespace(params.namespace) { - metadata+: { - labels+: { - SYNMonitoring: 'main', - } + com.makeMergeable(params.namespaceLabels), - }, +local namespace = ( + if params.monitoring.enabled && std.member(inv.applications, 'prometheus') then + prometheus.RegisterNamespace(kube.Namespace(params.namespace)) + else if params.monitoring.enabled && inv.parameters.facts.distribution == 'openshift4' then + kube.Namespace(params.namespace) { + metadata+: { + labels+: { 'openshift.io/cluster-monitoring': 'true' }, + }, + } + else + kube.Namespace(params.namespace) +) { + metadata+: { + labels+: com.makeMergeable(params.namespaceLabels), + }, }; local networkpolicy_infinispan_labels = { diff --git a/tests/golden/builtin/builtin/builtin/00_namespace.yaml b/tests/golden/builtin/builtin/builtin/00_namespace.yaml index 8e308acb..41ecf15e 100644 --- a/tests/golden/builtin/builtin/builtin/00_namespace.yaml +++ b/tests/golden/builtin/builtin/builtin/00_namespace.yaml @@ -3,7 +3,6 @@ kind: Namespace metadata: annotations: {} labels: - SYNMonitoring: main name: syn-builtin test: testing name: syn-builtin