Skip to content

Commit

Permalink
Merge pull request #50 from projectsyn/monitoring/prometheus
Browse files Browse the repository at this point in the history
Add support for component-prometheus
  • Loading branch information
TheBigLee authored Apr 11, 2023
2 parents c1ba0b4 + 115aed8 commit 8b3984c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ parameters:
enabled: true
prometheus_rule_labels:
prometheus: platform
instance: null
providers: {}
serviceAccounts: {}
clusterRoles: {}
Expand Down
13 changes: 12 additions & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local com = import 'lib/commodore.libjsonnet';
local crossplane = import 'lib/crossplane.libsonnet';
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.crossplane;
Expand Down Expand Up @@ -100,8 +101,18 @@ local rbacFinalizerRoleBinding = kube.ClusterRoleBinding('crossplane-rbac-manage
],
};

local namespace =
if params.monitoring.enabled && std.member(inv.applications, 'prometheus') then
if params.monitoring.instance != null then
prometheus.RegisterNamespace(kube.Namespace(params.namespace), params.monitoring.instance)
else
prometheus.RegisterNamespace(kube.Namespace(params.namespace))
else
kube.Namespace(params.namespace)
;

{
'00_namespace': kube.Namespace(params.namespace),
'00_namespace': namespace,
'01_rbac_finalizer_clusterrole': rbacFinalizerRole,
'01_rbac_finalizer_clusterrolebinding': rbacFinalizerRoleBinding,
[if std.length(providers) > 0 then '10_providers']: providers,
Expand Down
8 changes: 8 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ default:: `{"prometheus":"platform"}`
Labels to set on the alert rule configuration.
Can be used to ensure prometheus-operator picks up the `PrometheusRule` object by setting appropriate labels.

== `monitoring.instance`

[horizontal]
type:: string
default:: `null`

Which prometheus instance to use when setting the namespace label. If not set it will use the instance defined in `prometheus.defaultInstance`

== `serviceAccounts`

[horizontal]
Expand Down

0 comments on commit 8b3984c

Please sign in to comment.