...

Source file src/k8s.io/kubernetes/cmd/kube-controller-manager/app/options/namespacecontroller.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  	namespaceconfig "k8s.io/kubernetes/pkg/controller/namespace/config"
    23  )
    24  
    25  // NamespaceControllerOptions holds the NamespaceController options.
    26  type NamespaceControllerOptions struct {
    27  	*namespaceconfig.NamespaceControllerConfiguration
    28  }
    29  
    30  // AddFlags adds flags related to NamespaceController for controller manager to the specified FlagSet.
    31  func (o *NamespaceControllerOptions) AddFlags(fs *pflag.FlagSet) {
    32  	if o == nil {
    33  		return
    34  	}
    35  
    36  	fs.DurationVar(&o.NamespaceSyncPeriod.Duration, "namespace-sync-period", o.NamespaceSyncPeriod.Duration, "The period for syncing namespace life-cycle updates")
    37  	fs.Int32Var(&o.ConcurrentNamespaceSyncs, "concurrent-namespace-syncs", o.ConcurrentNamespaceSyncs, "The number of namespace objects that are allowed to sync concurrently. Larger number = more responsive namespace termination, but more CPU (and network) load")
    38  }
    39  
    40  // ApplyTo fills up NamespaceController config with options.
    41  func (o *NamespaceControllerOptions) ApplyTo(cfg *namespaceconfig.NamespaceControllerConfiguration) error {
    42  	if o == nil {
    43  		return nil
    44  	}
    45  
    46  	cfg.NamespaceSyncPeriod = o.NamespaceSyncPeriod
    47  	cfg.ConcurrentNamespaceSyncs = o.ConcurrentNamespaceSyncs
    48  
    49  	return nil
    50  }
    51  
    52  // Validate checks validation of NamespaceControllerOptions.
    53  func (o *NamespaceControllerOptions) Validate() []error {
    54  	if o == nil {
    55  		return nil
    56  	}
    57  
    58  	errs := []error{}
    59  	return errs
    60  }
    61  

View as plain text