type Reconciler … type ReconcilerOption … // WithTrafficDistributionEnabled controls whether the Reconciler considers the // `trafficDistribution` field while reconciling EndpointSlices. func WithTrafficDistributionEnabled(enabled bool) ReconcilerOption { … } type endpointMeta … // Reconcile takes a set of pods currently matching a service selector and // compares them with the endpoints already present in any existing endpoint // slices for the given service. It creates, updates, or deletes endpoint slices // to ensure the desired set of pods are represented by endpoint slices. func (r *Reconciler) Reconcile(logger klog.Logger, service *corev1.Service, pods []*corev1.Pod, existingSlices []*discovery.EndpointSlice, triggerTime time.Time) error { … } // reconcileByAddressType takes a set of pods currently matching a service selector and // compares them with the endpoints already present in any existing endpoint // slices (by address type) for the given service. It creates, updates, or deletes endpoint slices // to ensure the desired set of pods are represented by endpoint slices. func (r *Reconciler) reconcileByAddressType(logger klog.Logger, service *corev1.Service, pods []*corev1.Pod, existingSlices []*discovery.EndpointSlice, triggerTime time.Time, addressType discovery.AddressType) error { … } func NewReconciler(client clientset.Interface, nodeLister corelisters.NodeLister, maxEndpointsPerSlice int32, endpointSliceTracker *endpointsliceutil.EndpointSliceTracker, topologyCache *topologycache.TopologyCache, eventRecorder record.EventRecorder, controllerName string, options ...ReconcilerOption) *Reconciler { … } var placeholderSliceCompare … // finalize creates, updates, and deletes slices as specified func (r *Reconciler) finalize( service *corev1.Service, slicesToCreate, slicesToUpdate, slicesToDelete []*discovery.EndpointSlice, triggerTime time.Time, ) error { … } // reconcileByPortMapping compares the endpoints found in existing slices with // the list of desired endpoints and returns lists of slices to create, update, // and delete. It also checks that the slices mirror the parent services labels. // The logic is split up into several main steps: // 1. Iterate through existing slices, delete endpoints that are no longer // desired and update matching endpoints that have changed. It also checks // if the slices have the labels of the parent services, and updates them if not. // 2. Iterate through slices that have been modified in 1 and fill them up with // any remaining desired endpoints. // 3. If there still desired endpoints left, try to fit them into a previously // unchanged slice and/or create new ones. func (r *Reconciler) reconcileByPortMapping( logger klog.Logger, service *corev1.Service, existingSlices []*discovery.EndpointSlice, desiredSet endpointsliceutil.EndpointSet, endpointMeta *endpointMeta, ) ([]*discovery.EndpointSlice, []*discovery.EndpointSlice, []*discovery.EndpointSlice, int, int) { … } func (r *Reconciler) DeleteService(namespace, name string) { … } func (r *Reconciler) GetControllerName() string { … } // ManagedByChanged returns true if one of the provided EndpointSlices is // managed by the EndpointSlice controller while the other is not. func (r *Reconciler) ManagedByChanged(endpointSlice1, endpointSlice2 *discovery.EndpointSlice) bool { … } // ManagedByController returns true if the controller of the provided // EndpointSlices is the EndpointSlice controller. func (r *Reconciler) ManagedByController(endpointSlice *discovery.EndpointSlice) bool { … }