Documentation ¶
Index ¶
- func EndpointsEqualBeyondHash(ep1, ep2 *discovery.Endpoint) bool
- func GetPodFromDeleteAction(obj interface{}) *v1.Pod
- func GetPodServiceMemberships(serviceLister v1listers.ServiceLister, pod *v1.Pod) (sets.String, error)
- func GetServicesToUpdateOnPodChange(serviceLister v1listers.ServiceLister, old, cur interface{}) sets.String
- func IsPodReady(pod *v1.Pod) bool
- func ShouldPodBeInEndpoints(pod *v1.Pod, includeTerminating bool) bool
- func ShouldSetHostname(pod *v1.Pod, svc *v1.Service) bool
- type EndpointSet
- func (s EndpointSet) Delete(items ...*discovery.Endpoint) EndpointSet
- func (s EndpointSet) Get(item *discovery.Endpoint) *discovery.Endpoint
- func (s EndpointSet) Has(item *discovery.Endpoint) bool
- func (s EndpointSet) Insert(items ...*discovery.Endpoint) EndpointSet
- func (s EndpointSet) Len() int
- func (s EndpointSet) PopAny() (*discovery.Endpoint, bool)
- func (s EndpointSet) UnsortedList() []*discovery.Endpoint
- type EndpointSliceTracker
- func (est *EndpointSliceTracker) DeleteService(namespace, name string)
- func (est *EndpointSliceTracker) ExpectDeletion(endpointSlice *discovery.EndpointSlice)
- func (est *EndpointSliceTracker) GenerationsForSliceUnsafe(endpointSlice *discovery.EndpointSlice) (GenerationsBySlice, bool)
- func (est *EndpointSliceTracker) HandleDeletion(endpointSlice *discovery.EndpointSlice) bool
- func (est *EndpointSliceTracker) Has(endpointSlice *discovery.EndpointSlice) bool
- func (est *EndpointSliceTracker) ShouldSync(endpointSlice *discovery.EndpointSlice) bool
- func (est *EndpointSliceTracker) StaleSlices(service *v1.Service, endpointSlices []*discovery.EndpointSlice) bool
- func (est *EndpointSliceTracker) Update(endpointSlice *discovery.EndpointSlice)
- type GenerationsBySlice
- type PortMapKey
- type ServiceKey
- type ServiceState
- type TriggerTimeTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EndpointsEqualBeyondHash ¶
EndpointsEqualBeyondHash returns true if endpoints have equal attributes but excludes equality checks that would have already been covered with endpoint hashing (see hashEndpoint func for more info) and ignores difference in ResourceVersion of TargetRef.
func GetPodFromDeleteAction ¶
GetPodFromDeleteAction returns a pointer to a pod if one can be derived from obj (could be a *v1.Pod, or a DeletionFinalStateUnknown marker item).
func GetPodServiceMemberships ¶
func GetPodServiceMemberships(serviceLister v1listers.ServiceLister, pod *v1.Pod) (sets.String, error)
GetPodServiceMemberships returns a set of Service keys for Services that have a selector matching the given pod.
func GetServicesToUpdateOnPodChange ¶
func GetServicesToUpdateOnPodChange(serviceLister v1listers.ServiceLister, old, cur interface{}) sets.String
GetServicesToUpdateOnPodChange returns a set of Service keys for Services that have potentially been affected by a change to this pod.
func IsPodReady ¶
IsPodReady returns true if Pods Ready condition is true copied from k8s.io/kubernetes/pkg/api/v1/pod
func ShouldPodBeInEndpoints ¶
ShouldPodBeInEndpoints returns true if a specified pod should be in an Endpoints or EndpointSlice resource. Terminating pods are only included if includeTerminating is true.
Types ¶
type EndpointSet ¶
EndpointSet provides simple methods for comparing sets of Endpoints.
func (EndpointSet) Delete ¶
func (s EndpointSet) Delete(items ...*discovery.Endpoint) EndpointSet
Delete removes all items from the set.
func (EndpointSet) Get ¶
func (s EndpointSet) Get(item *discovery.Endpoint) *discovery.Endpoint
Returns an endpoint matching the hash if contained in the set.
func (EndpointSet) Has ¶
func (s EndpointSet) Has(item *discovery.Endpoint) bool
Has returns true if and only if item is contained in the set.
func (EndpointSet) Insert ¶
func (s EndpointSet) Insert(items ...*discovery.Endpoint) EndpointSet
Insert adds items to the set.
func (EndpointSet) PopAny ¶
func (s EndpointSet) PopAny() (*discovery.Endpoint, bool)
Returns a single element from the set.
func (EndpointSet) UnsortedList ¶
func (s EndpointSet) UnsortedList() []*discovery.Endpoint
UnsortedList returns the slice with contents in random order.
type EndpointSliceTracker ¶
type EndpointSliceTracker struct {
// contains filtered or unexported fields
}
EndpointSliceTracker tracks EndpointSlices and their associated generation to help determine if a change to an EndpointSlice has been processed by the EndpointSlice controller.
func NewEndpointSliceTracker ¶
func NewEndpointSliceTracker() *EndpointSliceTracker
NewEndpointSliceTracker creates and initializes a new endpointSliceTracker.
func (*EndpointSliceTracker) DeleteService ¶
func (est *EndpointSliceTracker) DeleteService(namespace, name string)
DeleteService removes the set of generations tracked for the Service.
func (*EndpointSliceTracker) ExpectDeletion ¶
func (est *EndpointSliceTracker) ExpectDeletion(endpointSlice *discovery.EndpointSlice)
ExpectDeletion sets the generation to deletionExpected in this endpointSliceTracker for the provided EndpointSlice.
func (*EndpointSliceTracker) GenerationsForSliceUnsafe ¶
func (est *EndpointSliceTracker) GenerationsForSliceUnsafe(endpointSlice *discovery.EndpointSlice) (GenerationsBySlice, bool)
GenerationsForSliceUnsafe returns the generations for the Service corresponding to the provided EndpointSlice, and a bool to indicate if it exists. A lock must be applied before calling this function.
func (*EndpointSliceTracker) HandleDeletion ¶
func (est *EndpointSliceTracker) HandleDeletion(endpointSlice *discovery.EndpointSlice) bool
HandleDeletion removes the generation in this endpointSliceTracker for the provided EndpointSlice. This returns true if the tracker expected this EndpointSlice to be deleted and false if not.
func (*EndpointSliceTracker) Has ¶
func (est *EndpointSliceTracker) Has(endpointSlice *discovery.EndpointSlice) bool
Has returns true if the endpointSliceTracker has a generation for the provided EndpointSlice.
func (*EndpointSliceTracker) ShouldSync ¶
func (est *EndpointSliceTracker) ShouldSync(endpointSlice *discovery.EndpointSlice) bool
ShouldSync returns true if this endpointSliceTracker does not have a generation for the provided EndpointSlice or it is greater than the generation of the tracked EndpointSlice.
func (*EndpointSliceTracker) StaleSlices ¶
func (est *EndpointSliceTracker) StaleSlices(service *v1.Service, endpointSlices []*discovery.EndpointSlice) bool
StaleSlices returns true if any of the following are true:
- One or more of the provided EndpointSlices have older generations than the corresponding tracked ones.
- The tracker is expecting one or more of the provided EndpointSlices to be deleted. (EndpointSlices that have already been marked for deletion are ignored here.)
- The tracker is tracking EndpointSlices that have not been provided.
func (*EndpointSliceTracker) Update ¶
func (est *EndpointSliceTracker) Update(endpointSlice *discovery.EndpointSlice)
Update adds or updates the generation in this endpointSliceTracker for the provided EndpointSlice.
type GenerationsBySlice ¶
GenerationsBySlice tracks expected EndpointSlice generations by EndpointSlice uid. A value of deletionExpected (-1) may be used here to indicate that we expect this EndpointSlice to be deleted.
type PortMapKey ¶
type PortMapKey string
PortMapKey is used to uniquely identify groups of endpoint ports.
func NewPortMapKey ¶
func NewPortMapKey(endpointPorts []discovery.EndpointPort) PortMapKey
NewPortMapKey generates a PortMapKey from endpoint ports.
type ServiceKey ¶
type ServiceKey struct {
// namespace, name composing a namespaced name - an unique identifier of every Service.
Namespace, Name string
}
ServiceKey is a key uniquely identifying a Service.
type ServiceState ¶
type ServiceState struct {
// contains filtered or unexported fields
}
ServiceState represents a state of an Service object that is known to this util.
type TriggerTimeTracker ¶
type TriggerTimeTracker struct { // ServiceStates is a map, indexed by Service object key, storing the last // known Service object state observed during the most recent call of the // ComputeEndpointLastChangeTriggerTime function. ServiceStates map[ServiceKey]ServiceState // contains filtered or unexported fields }
TriggerTimeTracker is used to compute an EndpointsLastChangeTriggerTime annotation. See the documentation for that annotation for more details.
Please note that this util may compute a wrong EndpointsLastChangeTriggerTime if the same object changes multiple times between two consecutive syncs. We're aware of this limitation but we decided to accept it, as fixing it would require a major rewrite of the endpoint(Slice) controller and Informer framework. Such situations, i.e. frequent updates of the same object in a single sync period, should be relatively rare and therefore this util should provide a good approximation of the EndpointsLastChangeTriggerTime.
func NewTriggerTimeTracker ¶
func NewTriggerTimeTracker() *TriggerTimeTracker
NewTriggerTimeTracker creates a new instance of the TriggerTimeTracker.
func (*TriggerTimeTracker) ComputeEndpointLastChangeTriggerTime ¶
func (t *TriggerTimeTracker) ComputeEndpointLastChangeTriggerTime( namespace string, service *v1.Service, pods []*v1.Pod) time.Time
ComputeEndpointLastChangeTriggerTime updates the state of the Service/Endpoint object being synced and returns the time that should be exported as the EndpointsLastChangeTriggerTime annotation.
If the method returns a 'zero' time the EndpointsLastChangeTriggerTime annotation shouldn't be exported.
Please note that this function may compute a wrong value if the same object (pod/service) changes multiple times between two consecutive syncs.
Important: This method is go-routing safe but only when called for different keys. The method shouldn't be called concurrently for the same key! This contract is fulfilled in the current implementation of the endpoint(slice) controller.
func (*TriggerTimeTracker) DeleteService ¶
func (t *TriggerTimeTracker) DeleteService(namespace, name string)
DeleteService deletes service state stored in this util.