diff --git a/controllers/admissionpolicy_controller.go b/controllers/admissionpolicy_controller.go index 2706dc788..d5033bbd7 100644 --- a/controllers/admissionpolicy_controller.go +++ b/controllers/admissionpolicy_controller.go @@ -26,6 +26,7 @@ import ( "github.com/kubewarden/kubewarden-controller/internal/pkg/constants" "github.com/kubewarden/kubewarden-controller/internal/pkg/naming" policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -88,8 +89,9 @@ func (r *AdmissionPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { &policiesv1.PolicyServer{}, handler.EnqueueRequestsFromMapFunc(r.findAdmissionPoliciesForPolicyServer), ). + Owns(&admissionregistrationv1.ValidatingWebhookConfiguration{}). + Owns(&admissionregistrationv1.MutatingWebhookConfiguration{}). Complete(r) - if err != nil { return errors.Join(errors.New("failed enrolling controller with manager"), err) } diff --git a/controllers/clusteradmissionpolicy_controller.go b/controllers/clusteradmissionpolicy_controller.go index 36eac88ba..4ba7bb173 100644 --- a/controllers/clusteradmissionpolicy_controller.go +++ b/controllers/clusteradmissionpolicy_controller.go @@ -26,6 +26,7 @@ import ( "github.com/kubewarden/kubewarden-controller/internal/pkg/constants" "github.com/kubewarden/kubewarden-controller/internal/pkg/naming" policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -88,8 +89,9 @@ func (r *ClusterAdmissionPolicyReconciler) SetupWithManager(mgr ctrl.Manager) er &policiesv1.PolicyServer{}, handler.EnqueueRequestsFromMapFunc(r.findClusterAdmissionPoliciesForPolicyServer), ). + Owns(&admissionregistrationv1.ValidatingWebhookConfiguration{}). + Owns(&admissionregistrationv1.MutatingWebhookConfiguration{}). Complete(r) - if err != nil { return errors.Join(errors.New("failed enrolling controller with manager"), err) }