...

Source file src/k8s.io/kubernetes/pkg/controlplane/reconcilers/reconcilers.go

Documentation: k8s.io/kubernetes/pkg/controlplane/reconcilers

     1  /*
     2  Copyright 2017 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 reconcilers Endpoint Reconcilers for the apiserver
    18  package reconcilers
    19  
    20  import (
    21  	"net"
    22  
    23  	corev1 "k8s.io/api/core/v1"
    24  )
    25  
    26  // EndpointReconciler knows how to reconcile the endpoints for the apiserver service.
    27  type EndpointReconciler interface {
    28  	// ReconcileEndpoints sets the endpoints for the given apiserver service (ro or rw).
    29  	// ReconcileEndpoints expects that the endpoints objects it manages will all be
    30  	// managed only by ReconcileEndpoints; therefore, to understand this, you need only
    31  	// understand the requirements.
    32  	//
    33  	// Requirements:
    34  	//  * All apiservers MUST use the same ports for their {rw, ro} services.
    35  	//  * All apiservers MUST use ReconcileEndpoints and only ReconcileEndpoints to manage the
    36  	//      endpoints for their {rw, ro} services.
    37  	//  * ReconcileEndpoints is called periodically from all apiservers.
    38  	ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort, reconcilePorts bool) error
    39  	// RemoveEndpoints removes this apiserver's lease.
    40  	RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error
    41  	// StopReconciling turns any later ReconcileEndpoints call into a noop.
    42  	StopReconciling()
    43  	// Destroy shuts down all internal structures.
    44  	// Destroy needs to be implemented in thread-safe way and be prepared for being
    45  	// called more than once.
    46  	Destroy()
    47  }
    48  
    49  // Type the reconciler type
    50  type Type string
    51  
    52  const (
    53  	// MasterCountReconcilerType will select the original reconciler
    54  	MasterCountReconcilerType Type = "master-count"
    55  	// LeaseEndpointReconcilerType will select a storage based reconciler
    56  	LeaseEndpointReconcilerType Type = "lease"
    57  	// NoneEndpointReconcilerType will turn off the endpoint reconciler
    58  	NoneEndpointReconcilerType Type = "none"
    59  )
    60  
    61  // Types an array of reconciler types
    62  type Types []Type
    63  
    64  // AllTypes export all reconcilers
    65  var AllTypes = Types{
    66  	MasterCountReconcilerType,
    67  	LeaseEndpointReconcilerType,
    68  	NoneEndpointReconcilerType,
    69  }
    70  
    71  // Names returns a slice of all the reconciler names
    72  func (t Types) Names() []string {
    73  	strs := make([]string, len(t))
    74  	for i, v := range t {
    75  		strs[i] = string(v)
    76  	}
    77  	return strs
    78  }
    79  

View as plain text