kubernetesk8s.io/kubernetes/test/e2e/framework/endpointslice Index | Files

package endpointslice

import "k8s.io/kubernetes/test/e2e/framework/endpointslice"

Index

Constants

const (
	// ControllerUpdateTimeout is the maximum expected wait before a change to a Pod
	// or Service is reflected in its EndpointSlices. (This is the same as
	// e2eservice.ServiceEndpointsTimeout, but duplicated here to avoid import loops.)
	ControllerUpdateTimeout = 2 * time.Minute
)

Functions

func WaitForEndpointCount

func WaitForEndpointCount(ctx context.Context, cs clientset.Interface, namespace, serviceName string, expectNum int) error

WaitForEndpointCount waits (up to ControllerUpdateTimeout) for the named service to have at least one EndpointSlice, where the total length of the `Endpoints` arrays across all EndpointSlices is expectNum. (For simple services, this is equivalent to saying that it waits for there to be exactly expectNum pods backing the service, but for dual-stack services or some services with named ports, the mapping between `Endpoints` and pods may not be 1-to-1. Note also that waiting for 0 endpoints means "wait for the Service to exist but not have any endpoints", not "wait for the Service to be deleted".)

func WaitForEndpointPods

func WaitForEndpointPods(ctx context.Context, cs clientset.Interface, namespace, serviceName string, expectPods ...string) error

WaitForEndpointPods waits (up to ControllerUpdateTimeout) for the named service to have at least one EndpointSlice, with the set of `Endpoints` across all slices covering exactly the pods named in expectPods. (Note that if called on a dual-stack service, it may return before both EndpointSlices have been written, since the first EndpointSlice alone will normally target all pods.)

func WaitForEndpointPorts

func WaitForEndpointPorts(ctx context.Context, cs clientset.Interface, namespace, service string, portMappings []PortMapping) error

WaitForEndpointPorts waits (up to ControllerUpdateTimeout) for the named service to have at least one EndpointSlice, with the set of `Endpoints` across all slices having endpoints covering exactly portMappings. (Note that if called on a dual-stack service, it may return before all EndpointSlices have been written, since just the EndpointSlices for a single family will normally target all ports.)

func WaitForEndpointSlices

func WaitForEndpointSlices(ctx context.Context, cs clientset.Interface, namespace, serviceName string, interval, timeout time.Duration, conditionFunc EndpointSliceConditionFunc) error

WaitForEndpointSlices is an EndpointSlice-specific wrapper around wait.PollUntilContextTimeout that polls conditionFunc with a list of serviceName's EndpointSlices.

Types

type EndpointSliceConditionFunc

type EndpointSliceConditionFunc func(ctx context.Context, endpointSlices []discoveryv1.EndpointSlice) (done bool, err error)

type FullPortsByPodUID

type FullPortsByPodUID map[types.UID][]v1.ContainerPort

FullPortsByPodUID is a map that maps pod UID to container ports.

func GetFullContainerPortsByPodUID

func GetFullContainerPortsByPodUID(eps []discoveryv1.EndpointSlice) FullPortsByPodUID

GetFullContainerPortsByPodUID returns a PortsByPodUID map on the given endpoints.

type PortMapping

type PortMapping struct {
	// Name is the name of the ServicePort / EndpointPort
	Name string
	// Protocol is the protocol (defaults to TCP if left empty)
	Protocol v1.Protocol
	// Target is the name of the endpoint Pod
	Target string
	// TargetPort is the port on Target
	TargetPort int32
}

PortMapping contains data used by WaitForEndpointPorts

type PortsByPodUID

type PortsByPodUID map[types.UID][]int

PortsByPodUID is a map that maps pod UID to container ports.

func GetContainerPortsByPodUID

func GetContainerPortsByPodUID(eps []discoveryv1.EndpointSlice) PortsByPodUID

GetContainerPortsByPodUID returns a PortsByPodUID map on the given endpoints.

Source Files

ports.go wait.go

Version
v1.34.0-rc.0
Published
Aug 6, 2025
Platform
linux/amd64
Imports
11 packages
Last checked
2 minutes ago

Tools for package owners.