Skip to content

Commit

Permalink
Add rbac for smon and ing
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuCesbron committed Feb 19, 2024
1 parent 3e6fc62 commit 10c949b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions charts/operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: immudb-operator
description: Helm chart to deploy [unagex-immudb-operator](https://github.com/unagex/immudb-operator)
type: application
version: 0.0.7
appVersion: 0.0.7
version: 0.0.8
appVersion: 0.0.8
home: https://github.com/unagex/immudb-operator
6 changes: 6 additions & 0 deletions charts/operator/templates/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ rules:
- apiGroups: [""]
resources: ["services"]
verbs: ["get", "list", "watch", "create", "update"]
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "list", "watch", "create", "update"]
- apiGroups: ["monitoring.coreos.com"]
resources: ["servicemonitors"]
verbs: ["get", "list", "watch", "create", "update"]
2 changes: 2 additions & 0 deletions internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
unagexcomv1 "github.com/unagex/immudb-operator/api/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"

Expand Down Expand Up @@ -104,5 +105,6 @@ func (r *ImmudbReconciler) SetupWithManager(mgr ctrl.Manager) error {
Watches(&appsv1.StatefulSet{}, filter).
Watches(&corev1.Service{}, filter).
Watches(&knetworkingv1.Ingress{}, filter).
Watches(&promv1.ServiceMonitor{}, filter).
Complete(r)
}
3 changes: 2 additions & 1 deletion internal/controller/service_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/unagex/immudb-operator/internal/controller/common"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"

promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
Expand Down Expand Up @@ -51,7 +52,7 @@ func (r *ImmudbReconciler) GetServiceMonitor(immudb *unagexcomv1.Immudb) *promv1
Name: immudb.Name,
Namespace: immudb.Namespace,
OwnerReferences: common.GetOwnerReferences(immudb),
Labels: immudb.Spec.ServiceMonitor.Labels,
Labels: labels.Merge(ls, immudb.Spec.ServiceMonitor.Labels),
},
Spec: promv1.ServiceMonitorSpec{
Selector: metav1.LabelSelector{
Expand Down

0 comments on commit 10c949b

Please # to comment.