Documentation ¶
Index ¶
- func DeepHashObjectToString(objectToWrite interface{}) string
- func EndpointsEqualBeyondHash(ep1, ep2 *discovery.Endpoint) bool
- func GetPodFromDeleteAction(obj interface{}) *v1.Pod
- func GetServicesToUpdateOnPodChange(serviceLister v1listers.ServiceLister, selectorCache *ServiceSelectorCache, ...) sets.String
- func ShouldPodBeInEndpointSlice(pod *v1.Pod, includeTerminating bool) bool
- func ShouldSetHostname(pod *v1.Pod, svc *v1.Service) bool
- type PortMapKey
- type ServiceKey
- type ServiceSelectorCache
- func (sc *ServiceSelectorCache) Delete(key string)
- func (sc *ServiceSelectorCache) Get(key string) (labels.Selector, bool)
- func (sc *ServiceSelectorCache) GetPodServiceMemberships(serviceLister v1listers.ServiceLister, pod *v1.Pod) (sets.String, error)
- func (sc *ServiceSelectorCache) Update(key string, rawSelector map[string]string) labels.Selector
- type ServiceState
- type TriggerTimeTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepHashObjectToString ¶ added in v1.17.0
func DeepHashObjectToString(objectToWrite interface{}) string
DeepHashObjectToString creates a unique hash string from a go object.
func EndpointsEqualBeyondHash ¶ added in v1.21.0
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).
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 GetServicesToUpdateOnPodChange ¶
func GetServicesToUpdateOnPodChange(serviceLister v1listers.ServiceLister, selectorCache *ServiceSelectorCache, 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 ShouldPodBeInEndpointSlice ¶ added in v1.20.0
ShouldPodBeInEndpointSlice returns true if a specified pod should be in an EndpointSlice object. Terminating pods are only included if includeTerminating is true
Types ¶
type PortMapKey ¶ added in v1.17.0
type PortMapKey string
PortMapKey is used to uniquely identify groups of endpoint ports.
func NewPortMapKey ¶ added in v1.17.0
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 ServiceSelectorCache ¶ added in v1.17.0
type ServiceSelectorCache struct {
// contains filtered or unexported fields
}
ServiceSelectorCache is a cache of service selectors to avoid high CPU consumption caused by frequent calls to AsSelectorPreValidated (see #73527)
func NewServiceSelectorCache ¶ added in v1.17.0
func NewServiceSelectorCache() *ServiceSelectorCache
NewServiceSelectorCache init ServiceSelectorCache for both endpoint controller and endpointSlice controller.
func (*ServiceSelectorCache) Delete ¶ added in v1.17.0
func (sc *ServiceSelectorCache) Delete(key string)
Delete can delete selector which exist in ServiceSelectorCache.
func (*ServiceSelectorCache) Get ¶ added in v1.17.0
func (sc *ServiceSelectorCache) Get(key string) (labels.Selector, bool)
Get return selector and existence in ServiceSelectorCache by key.
func (*ServiceSelectorCache) GetPodServiceMemberships ¶ added in v1.17.0
func (sc *ServiceSelectorCache) 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.
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.