...

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

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

     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 app implements a server that runs a set of active
    18  // components.  This includes replication controllers, service endpoints and
    19  // nodes.
    20  package app
    21  
    22  import (
    23  	"context"
    24  
    25  	"k8s.io/controller-manager/controller"
    26  	"k8s.io/kubernetes/cmd/kube-controller-manager/names"
    27  	endpointslicecontroller "k8s.io/kubernetes/pkg/controller/endpointslice"
    28  	endpointslicemirroringcontroller "k8s.io/kubernetes/pkg/controller/endpointslicemirroring"
    29  )
    30  
    31  func newEndpointSliceControllerDescriptor() *ControllerDescriptor {
    32  	return &ControllerDescriptor{
    33  		name:     names.EndpointSliceController,
    34  		aliases:  []string{"endpointslice"},
    35  		initFunc: startEndpointSliceController,
    36  	}
    37  }
    38  
    39  func startEndpointSliceController(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) {
    40  	go endpointslicecontroller.NewController(
    41  		ctx,
    42  		controllerContext.InformerFactory.Core().V1().Pods(),
    43  		controllerContext.InformerFactory.Core().V1().Services(),
    44  		controllerContext.InformerFactory.Core().V1().Nodes(),
    45  		controllerContext.InformerFactory.Discovery().V1().EndpointSlices(),
    46  		controllerContext.ComponentConfig.EndpointSliceController.MaxEndpointsPerSlice,
    47  		controllerContext.ClientBuilder.ClientOrDie("endpointslice-controller"),
    48  		controllerContext.ComponentConfig.EndpointSliceController.EndpointUpdatesBatchPeriod.Duration,
    49  	).Run(ctx, int(controllerContext.ComponentConfig.EndpointSliceController.ConcurrentServiceEndpointSyncs))
    50  	return nil, true, nil
    51  }
    52  
    53  func newEndpointSliceMirroringControllerDescriptor() *ControllerDescriptor {
    54  	return &ControllerDescriptor{
    55  		name:     names.EndpointSliceMirroringController,
    56  		aliases:  []string{"endpointslicemirroring"},
    57  		initFunc: startEndpointSliceMirroringController,
    58  	}
    59  }
    60  
    61  func startEndpointSliceMirroringController(ctx context.Context, controllerContext ControllerContext, controllerName string) (controller.Interface, bool, error) {
    62  	go endpointslicemirroringcontroller.NewController(
    63  		ctx,
    64  		controllerContext.InformerFactory.Core().V1().Endpoints(),
    65  		controllerContext.InformerFactory.Discovery().V1().EndpointSlices(),
    66  		controllerContext.InformerFactory.Core().V1().Services(),
    67  		controllerContext.ComponentConfig.EndpointSliceMirroringController.MirroringMaxEndpointsPerSubset,
    68  		controllerContext.ClientBuilder.ClientOrDie("endpointslicemirroring-controller"),
    69  		controllerContext.ComponentConfig.EndpointSliceMirroringController.MirroringEndpointUpdatesBatchPeriod.Duration,
    70  	).Run(ctx, int(controllerContext.ComponentConfig.EndpointSliceMirroringController.MirroringConcurrentServiceEndpointSyncs))
    71  	return nil, true, nil
    72  }
    73  

View as plain text