registry.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package install
  14. import (
  15. "k8s.io/apimachinery/pkg/runtime/schema"
  16. quota "k8s.io/kubernetes/pkg/quota/v1"
  17. core "k8s.io/kubernetes/pkg/quota/v1/evaluator/core"
  18. generic "k8s.io/kubernetes/pkg/quota/v1/generic"
  19. )
  20. // NewQuotaConfigurationForAdmission returns a quota configuration for admission control.
  21. func NewQuotaConfigurationForAdmission() quota.Configuration {
  22. evaluators := core.NewEvaluators(nil)
  23. return generic.NewConfiguration(evaluators, DefaultIgnoredResources())
  24. }
  25. // NewQuotaConfigurationForControllers returns a quota configuration for controllers.
  26. func NewQuotaConfigurationForControllers(f quota.ListerForResourceFunc) quota.Configuration {
  27. evaluators := core.NewEvaluators(f)
  28. return generic.NewConfiguration(evaluators, DefaultIgnoredResources())
  29. }
  30. // ignoredResources are ignored by quota by default
  31. var ignoredResources = map[schema.GroupResource]struct{}{
  32. {Group: "", Resource: "events"}: {},
  33. }
  34. // DefaultIgnoredResources returns the default set of resources that quota system
  35. // should ignore. This is exposed so downstream integrators can have access to them.
  36. func DefaultIgnoredResources() map[schema.GroupResource]struct{} {
  37. return ignoredResources
  38. }