diff --git a/controllers/grafana_controller.go b/controllers/grafana_controller.go index 9ab080bbd..75585923b 100644 --- a/controllers/grafana_controller.go +++ b/controllers/grafana_controller.go @@ -28,8 +28,10 @@ import ( "github.com/grafana/grafana-operator/v5/controllers/metrics" "github.com/grafana/grafana-operator/v5/controllers/reconcilers" "github.com/grafana/grafana-operator/v5/controllers/reconcilers/grafana" + routev1 "github.com/openshift/api/route/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + networkingv1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -295,12 +297,22 @@ func (r *GrafanaReconciler) syncStatuses(ctx context.Context) error { // SetupWithManager sets up the controller with the Manager. func (r *GrafanaReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error { - err := ctrl.NewControllerManagedBy(mgr). + b := ctrl.NewControllerManagedBy(mgr). For(&grafanav1beta1.Grafana{}, builder.WithPredicates(ignoreStatusUpdates())). Owns(&appsv1.Deployment{}, builder.WithPredicates(ignoreStatusUpdates())). Owns(&corev1.ConfigMap{}). - WithOptions(controller.Options{RateLimiter: defaultRateLimiter()}). - Complete(r) + Owns(&corev1.PersistentVolumeClaim{}, builder.WithPredicates(ignoreStatusUpdates())). + Owns(&corev1.Secret{}). + Owns(&corev1.ServiceAccount{}). + Owns(&corev1.Service{}, builder.WithPredicates(ignoreStatusUpdates())). + Owns(&networkingv1.Ingress{}, builder.WithPredicates(ignoreStatusUpdates())). + WithOptions(controller.Options{RateLimiter: defaultRateLimiter()}) + + if r.IsOpenShift { + b.Owns(&routev1.Route{}, builder.WithPredicates(ignoreStatusUpdates())) + } + + err := b.Complete(r) if err != nil { return err }