k8s.io/kubernetes@v1.29.3/pkg/quota/v1/install/registry.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package install 18 19 import ( 20 eventv1 "k8s.io/api/events/v1" 21 "k8s.io/apimachinery/pkg/runtime/schema" 22 quota "k8s.io/apiserver/pkg/quota/v1" 23 "k8s.io/apiserver/pkg/quota/v1/generic" 24 "k8s.io/kubernetes/pkg/apis/authentication" 25 "k8s.io/kubernetes/pkg/apis/authorization" 26 "k8s.io/kubernetes/pkg/quota/v1/evaluator/core" 27 ) 28 29 // NewQuotaConfigurationForAdmission returns a quota configuration for admission control. 30 func NewQuotaConfigurationForAdmission() quota.Configuration { 31 evaluators := core.NewEvaluators(nil) 32 return generic.NewConfiguration(evaluators, DefaultIgnoredResources()) 33 } 34 35 // NewQuotaConfigurationForControllers returns a quota configuration for controllers. 36 func NewQuotaConfigurationForControllers(f quota.ListerForResourceFunc) quota.Configuration { 37 evaluators := core.NewEvaluators(f) 38 return generic.NewConfiguration(evaluators, DefaultIgnoredResources()) 39 } 40 41 // ignoredResources are ignored by quota by default 42 var ignoredResources = map[schema.GroupResource]struct{}{ 43 // virtual resources that aren't stored and shouldn't be quota-ed 44 {Group: "", Resource: "bindings"}: {}, 45 {Group: "", Resource: "componentstatuses"}: {}, 46 {Group: authentication.GroupName, Resource: "tokenreviews"}: {}, 47 {Group: authentication.GroupName, Resource: "selfsubjectreviews"}: {}, 48 {Group: authorization.GroupName, Resource: "subjectaccessreviews"}: {}, 49 {Group: authorization.GroupName, Resource: "selfsubjectaccessreviews"}: {}, 50 {Group: authorization.GroupName, Resource: "localsubjectaccessreviews"}: {}, 51 {Group: authorization.GroupName, Resource: "selfsubjectrulesreviews"}: {}, 52 53 // events haven't been quota-ed before 54 {Group: "", Resource: "events"}: {}, 55 {Group: eventv1.GroupName, Resource: "events"}: {}, 56 } 57 58 // DefaultIgnoredResources returns the default set of resources that quota system 59 // should ignore. This is exposed so downstream integrators can have access to them. 60 func DefaultIgnoredResources() map[schema.GroupResource]struct{} { 61 return ignoredResources 62 }