Skip to content

Commit

Permalink
Merge pull request #98 from projectsyn/add_missing_monitoring_labels
Browse files Browse the repository at this point in the history
Add monitoring labels to support component-prometheus
  • Loading branch information
TheBigLee authored Sep 22, 2022
2 parents 79c3210 + 628f0e5 commit 6b1b3be
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 5 deletions.
10 changes: 9 additions & 1 deletion component/config.jsonnet
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local prometheus = import 'lib/prometheus.libsonnet';
local inv = kap.inventory();
local params = inv.parameters.argocd;

local namespace = kube.Namespace(params.namespace) {
local ns_metadata = {
metadata+: {
labels+: {
SYNMonitoring: 'main',
Expand All @@ -13,6 +14,13 @@ local namespace = kube.Namespace(params.namespace) {
},
};

local namespace =
if std.member(inv.applications, 'prometheus') then
prometheus.RegisterNamespace(kube.Namespace(params.namespace)) + ns_metadata
else
kube.Namespace(params.namespace) + ns_metadata
;

local config = [
kube.ConfigMap('argocd-cm') {
data: {
Expand Down
15 changes: 11 additions & 4 deletions component/monitoring.libsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local prometheus = import 'lib/prometheus.libsonnet';
local inv = kap.inventory();
local params = inv.parameters.argocd;

Expand Down Expand Up @@ -96,9 +97,15 @@ local grafana_dashboard =
},
};

local promEnable = function(obj)
if std.member(inv.applications, 'prometheus') then
prometheus.Enable(obj)
else obj
;

[
serviceMonitor('argocd-metrics'),
serviceMonitor('argocd-server-metrics'),
serviceMonitor('argocd-repo-server'),
alert_rules,
promEnable(serviceMonitor('argocd-metrics')),
promEnable(serviceMonitor('argocd-server-metrics')),
promEnable(serviceMonitor('argocd-repo-server')),
promEnable(alert_rules),
] + if params.monitoring.dashboards then [ grafana_dashboard ] else []
12 changes: 12 additions & 0 deletions tests/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
applications:
- prometheus

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

secret_management:
vault_role: test
vault_auth_mount_path: auth/lieutenant
vault_addr: test.syn.tools

prometheus:
defaultInstance: infra
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
SYNMonitoring: main
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/infra: 'true'
name: syn
openshift.io/cluster-monitoring: 'true'
name: syn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
app.kubernetes.io/name: argocd-metrics
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/enabled: 'true'
name: argocd-metrics
name: argocd-metrics
namespace: syn
Expand All @@ -23,6 +24,7 @@ metadata:
labels:
app.kubernetes.io/name: argocd-server-metrics
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/enabled: 'true'
name: argocd-server-metrics
name: argocd-server-metrics
namespace: syn
Expand All @@ -41,6 +43,7 @@ metadata:
labels:
app.kubernetes.io/name: argocd-repo-server
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/enabled: 'true'
name: argocd-repo-server
name: argocd-repo-server
namespace: syn
Expand All @@ -58,6 +61,7 @@ metadata:
annotations: {}
labels:
cluster_id: c-green-test-1234
monitoring.syn.tools/enabled: 'true'
name: argocd
prometheus: platform
role: alert-rules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
SYNMonitoring: main
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/infra: 'true'
name: syn
openshift.io/cluster-monitoring: 'true'
name: syn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
app.kubernetes.io/name: argocd-metrics
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/enabled: 'true'
name: argocd-metrics
name: argocd-metrics
namespace: syn
Expand All @@ -23,6 +24,7 @@ metadata:
labels:
app.kubernetes.io/name: argocd-server-metrics
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/enabled: 'true'
name: argocd-server-metrics
name: argocd-server-metrics
namespace: syn
Expand All @@ -41,6 +43,7 @@ metadata:
labels:
app.kubernetes.io/name: argocd-repo-server
app.kubernetes.io/part-of: argocd
monitoring.syn.tools/enabled: 'true'
name: argocd-repo-server
name: argocd-repo-server
namespace: syn
Expand All @@ -58,6 +61,7 @@ metadata:
annotations: {}
labels:
cluster_id: c-green-test-1234
monitoring.syn.tools/enabled: 'true'
name: argocd
prometheus: platform
role: alert-rules
Expand Down
12 changes: 12 additions & 0 deletions tests/openshift.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
applications:
- prometheus

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

secret_management:
vault_role: test
vault_addr: test.syn.tools

facts:
distribution: openshift4

prometheus:
defaultInstance: infra

0 comments on commit 6b1b3be

Please sign in to comment.