...

Source file src/k8s.io/kubernetes/cmd/kube-controller-manager/app/options/resourcequotacontroller.go

Documentation: k8s.io/kubernetes/cmd/kube-controller-manager/app/options

     1  /*
     2  Copyright 2018 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 options
    18  
    19  import (
    20  	"github.com/spf13/pflag"
    21  
    22  	resourcequotaconfig "k8s.io/kubernetes/pkg/controller/resourcequota/config"
    23  )
    24  
    25  // ResourceQuotaControllerOptions holds the ResourceQuotaController options.
    26  type ResourceQuotaControllerOptions struct {
    27  	*resourcequotaconfig.ResourceQuotaControllerConfiguration
    28  }
    29  
    30  // AddFlags adds flags related to ResourceQuotaController for controller manager to the specified FlagSet.
    31  func (o *ResourceQuotaControllerOptions) AddFlags(fs *pflag.FlagSet) {
    32  	if o == nil {
    33  		return
    34  	}
    35  
    36  	fs.DurationVar(&o.ResourceQuotaSyncPeriod.Duration, "resource-quota-sync-period", o.ResourceQuotaSyncPeriod.Duration, "The period for syncing quota usage status in the system")
    37  	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")
    38  }
    39  
    40  // ApplyTo fills up ResourceQuotaController config with options.
    41  func (o *ResourceQuotaControllerOptions) ApplyTo(cfg *resourcequotaconfig.ResourceQuotaControllerConfiguration) error {
    42  	if o == nil {
    43  		return nil
    44  	}
    45  
    46  	cfg.ResourceQuotaSyncPeriod = o.ResourceQuotaSyncPeriod
    47  	cfg.ConcurrentResourceQuotaSyncs = o.ConcurrentResourceQuotaSyncs
    48  
    49  	return nil
    50  }
    51  
    52  // Validate checks validation of ResourceQuotaControllerOptions.
    53  func (o *ResourceQuotaControllerOptions) Validate() []error {
    54  	if o == nil {
    55  		return nil
    56  	}
    57  
    58  	errs := []error{}
    59  	return errs
    60  }
    61  

View as plain text