Skip to content

Commit 01ad960

Browse files
authored
feat: create ClusterRoleBIndings based on API field (#888)
Signed-off-by: Jan Fajerski <[email protected]>
1 parent 76135c9 commit 01ad960

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ require (
3434
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20240404200104-96ed2d49b255
3535

3636
require (
37+
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251009091129-76135c924ed6
3738
github.com/rhobs/perses v0.0.0-20250612171017-5d7686af9ae4
3839
github.com/rhobs/perses-operator v0.1.10-0.20250612173146-78eb619430df
3940
github.com/stretchr/testify v1.11.1
@@ -117,7 +118,6 @@ require (
117118
github.com/prometheus/procfs v0.17.0 // indirect
118119
github.com/prometheus/prometheus v0.304.2 // indirect
119120
github.com/rhobs/obo-prometheus-operator/pkg/client v0.84.0-rhobs1 // indirect
120-
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251002144945-36f5667d6b8d // indirect
121121
github.com/shopspring/decimal v1.4.0 // indirect
122122
github.com/sirupsen/logrus v1.9.3 // indirect
123123
github.com/spf13/cobra v1.9.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.84.0-rhobs1 h1:N
380380
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.84.0-rhobs1/go.mod h1:XhxzqYHJ7vGkIelrVaNZeLp2pgj91HNuiRgPdj7S+yI=
381381
github.com/rhobs/obo-prometheus-operator/pkg/client v0.84.0-rhobs1 h1:R8JvmUX4FkC304JEh43TgUbmAXuFwBAWSZlHXB0AVew=
382382
github.com/rhobs/obo-prometheus-operator/pkg/client v0.84.0-rhobs1/go.mod h1:nc3DIXRuOYsEybYMdcH2V9BG2xSqtTFRq6Lcd1lOZYk=
383-
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251002144945-36f5667d6b8d h1:D0Eq4ZLDqLcy1TqNsrM+7pdhdzZDYHlPEG44HRPgC/o=
384-
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251002144945-36f5667d6b8d/go.mod h1:bNP815/mCv8ydNQ2Q3a9gqlx9b2XouWa6hws9vthq78=
383+
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251009091129-76135c924ed6 h1:f+J6l48RMDomN9YrDxd0cZVo7+L+a/TCzH6ycat5tMI=
384+
github.com/rhobs/observability-operator/pkg/apis v0.0.0-20251009091129-76135c924ed6/go.mod h1:bNP815/mCv8ydNQ2Q3a9gqlx9b2XouWa6hws9vthq78=
385385
github.com/rhobs/perses v0.0.0-20250612171017-5d7686af9ae4 h1:IxpxGJ/fbnRkZZYFm17NMedFyEuOKuf4TS23g+6jMvU=
386386
github.com/rhobs/perses v0.0.0-20250612171017-5d7686af9ae4/go.mod h1:Mxs4sXawWiV50qokKG1UZCV9NJEdJWsALY71/z38NKA=
387387
github.com/rhobs/perses-operator v0.1.10-0.20250612173146-78eb619430df h1:rwtqpvrowEF6EjSiO3PPcqC6s2jo7NU3VsGU6yrpxTg=

pkg/controllers/monitoring/monitoring-stack/components.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func stackComponentReconcilers(
5252
alertmanagerName := ms.Name + "-alertmanager"
5353
additionalScrapeConfigsSecretName := ms.Name + "-self-scrape"
5454
hasNsSelector := ms.Spec.NamespaceSelector != nil
55+
createCRB := hasNsSelector && ms.Spec.CreateClusterRoleBindings == stack.CreateClusterRoleBindings
5556
deployAlertmanager := !ms.Spec.AlertmanagerConfig.Disabled
5657

5758
return []reconciler.Reconciler{
@@ -70,13 +71,13 @@ func stackComponentReconcilers(
7071
// Alertmanager Deployment
7172
reconciler.NewOptionalUpdater(newServiceAccount(alertmanagerName, ms.Namespace), ms, deployAlertmanager),
7273
// create clusterrolebinding if nsSelector's present otherwise a rolebinding
73-
reconciler.NewOptionalUpdater(newClusterRoleBinding(ms, prometheusName), ms, hasNsSelector),
74+
reconciler.NewOptionalUpdater(newClusterRoleBinding(ms, prometheusName), ms, createCRB),
7475
reconciler.NewOptionalUpdater(newRoleBindingForClusterRole(ms, prometheusName), ms, !hasNsSelector),
7576

7677
reconciler.NewOptionalUpdater(newAlertManagerClusterRole(alertmanagerName, rbacVerbs), ms, deployAlertmanager),
7778

7879
// create clusterrolebinding if alertmanager is enabled and namespace selector is also present in MonitoringStack
79-
reconciler.NewOptionalUpdater(newClusterRoleBinding(ms, alertmanagerName), ms, deployAlertmanager && hasNsSelector),
80+
reconciler.NewOptionalUpdater(newClusterRoleBinding(ms, alertmanagerName), ms, deployAlertmanager && createCRB),
8081
reconciler.NewOptionalUpdater(newRoleBindingForClusterRole(ms, alertmanagerName), ms, deployAlertmanager && !hasNsSelector),
8182

8283
reconciler.NewOptionalUpdater(newAlertmanager(ms, alertmanagerName, alertmanager), ms, deployAlertmanager),

0 commit comments

Comments
 (0)