diff --git a/pkg/controller/workloadspread/workloadspread_controller.go b/pkg/controller/workloadspread/workloadspread_controller.go index f5e412af36..c9b4b63e60 100644 --- a/pkg/controller/workloadspread/workloadspread_controller.go +++ b/pkg/controller/workloadspread/workloadspread_controller.go @@ -45,6 +45,7 @@ import ( appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/openkruise/kruise/pkg/util" "github.com/openkruise/kruise/pkg/util/controllerfinder" + utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" "github.com/openkruise/kruise/pkg/util/fieldindex" "github.com/openkruise/kruise/pkg/util/ratelimiter" "github.com/openkruise/kruise/pkg/util/requeueduration" @@ -74,6 +75,7 @@ const ( ) var ( + controllerKruiseKindWS = appsv1alpha1.SchemeGroupVersion.WithKind("WorkloadSpread") controllerKruiseKindCS = appsv1alpha1.SchemeGroupVersion.WithKind("CloneSet") controllerKindRS = appsv1.SchemeGroupVersion.WithKind("ReplicaSet") controllerKindDep = appsv1.SchemeGroupVersion.WithKind("Deployment") @@ -86,6 +88,9 @@ var durationStore = requeueduration.DurationStore{} // Add creates a new WorkloadSpread Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(mgr manager.Manager) error { + if !utildiscovery.DiscoverGVK(controllerKruiseKindWS) { + return nil + } return add(mgr, newReconciler(mgr)) }