diff --git a/pkg/kubeapiserver/options/plugins.go b/pkg/kubeapiserver/options/plugins.go index 0f3ae7790ba..ed63fb844a5 100644 --- a/pkg/kubeapiserver/options/plugins.go +++ b/pkg/kubeapiserver/options/plugins.go @@ -55,8 +55,6 @@ import ( "k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle" mutatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/mutating" validatingwebhook "k8s.io/apiserver/pkg/admission/plugin/webhook/validating" - utilfeature "k8s.io/apiserver/pkg/util/feature" - "k8s.io/kubernetes/pkg/features" ) // AllOrderedPlugins is the list of all the plugins in order. @@ -143,11 +141,8 @@ func DefaultOffAdmissionPlugins() sets.String { storageobjectinuseprotection.PluginName, //StorageObjectInUseProtection podpriority.PluginName, //PodPriority nodetaint.PluginName, //TaintNodesByCondition + runtimeclass.PluginName, //RuntimeClass, gates internally on the feature ) - if utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) { - defaultOnPlugins.Insert(runtimeclass.PluginName) //RuntimeClass - } - return sets.NewString(AllOrderedPlugins...).Difference(defaultOnPlugins) } diff --git a/plugin/pkg/admission/runtimeclass/admission.go b/plugin/pkg/admission/runtimeclass/admission.go index b8c9831546a..8f1731bbd02 100644 --- a/plugin/pkg/admission/runtimeclass/admission.go +++ b/plugin/pkg/admission/runtimeclass/admission.go @@ -67,6 +67,9 @@ var _ genericadmissioninitailizer.WantsExternalKubeInformerFactory = &RuntimeCla // SetExternalKubeInformerFactory implements the WantsExternalKubeInformerFactory interface. func (r *RuntimeClass) SetExternalKubeInformerFactory(f informers.SharedInformerFactory) { + if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) { + return + } runtimeClassInformer := f.Node().V1beta1().RuntimeClasses() r.SetReadyFunc(runtimeClassInformer.Informer().HasSynced) r.runtimeClassLister = runtimeClassInformer.Lister() @@ -74,6 +77,9 @@ func (r *RuntimeClass) SetExternalKubeInformerFactory(f informers.SharedInformer // ValidateInitialization implements the WantsExternalKubeInformerFactory interface. func (r *RuntimeClass) ValidateInitialization() error { + if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) { + return nil + } if r.runtimeClassLister == nil { return fmt.Errorf("missing RuntimeClass lister") } @@ -110,6 +116,10 @@ func (r *RuntimeClass) Admit(ctx context.Context, attributes admission.Attribute // Validate makes sure that pod adhere's to RuntimeClass's definition func (r *RuntimeClass) Validate(ctx context.Context, attributes admission.Attributes, o admission.ObjectInterfaces) error { + if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) { + return nil + } + // Ignore all calls to subresources or resources other than pods. if shouldIgnore(attributes) { return nil