resourcequotacontroller.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Copyright 2018 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 options
  14. import (
  15. "github.com/spf13/pflag"
  16. resourcequotaconfig "k8s.io/kubernetes/pkg/controller/resourcequota/config"
  17. )
  18. // ResourceQuotaControllerOptions holds the ResourceQuotaController options.
  19. type ResourceQuotaControllerOptions struct {
  20. *resourcequotaconfig.ResourceQuotaControllerConfiguration
  21. }
  22. // AddFlags adds flags related to ResourceQuotaController for controller manager to the specified FlagSet.
  23. func (o *ResourceQuotaControllerOptions) AddFlags(fs *pflag.FlagSet) {
  24. if o == nil {
  25. return
  26. }
  27. fs.DurationVar(&o.ResourceQuotaSyncPeriod.Duration, "resource-quota-sync-period", o.ResourceQuotaSyncPeriod.Duration, "The period for syncing quota usage status in the system")
  28. fs.Int32Var(&o.ConcurrentResourceQuotaSyncs, "concurrent-resource-quota-syncs", o.ConcurrentResourceQuotaSyncs, "The number of resource quotas that are allowed to sync concurrently. Larger number = more responsive quota management, but more CPU (and network) load")
  29. }
  30. // ApplyTo fills up ResourceQuotaController config with options.
  31. func (o *ResourceQuotaControllerOptions) ApplyTo(cfg *resourcequotaconfig.ResourceQuotaControllerConfiguration) error {
  32. if o == nil {
  33. return nil
  34. }
  35. cfg.ResourceQuotaSyncPeriod = o.ResourceQuotaSyncPeriod
  36. cfg.ConcurrentResourceQuotaSyncs = o.ConcurrentResourceQuotaSyncs
  37. return nil
  38. }
  39. // Validate checks validation of ResourceQuotaControllerOptions.
  40. func (o *ResourceQuotaControllerOptions) Validate() []error {
  41. if o == nil {
  42. return nil
  43. }
  44. errs := []error{}
  45. return errs
  46. }