types

package
v1.26.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 41 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TestZone1            = "zone1"
	TestZone2            = "zone2"
	TestZone3            = "zone3"
	TestZone4            = "zone4"
	TestInstance1        = "instance1"
	TestInstance2        = "instance2"
	TestInstance3        = "instance3"
	TestInstance4        = "instance4"
	TestInstance5        = "instance5"
	TestInstance6        = "instance6"
	TestUnreadyInstance1 = "unready-instance1"
	TestUnreadyInstance2 = "unready-instance2"
	TestUpgradeInstance1 = "upgrade-instance1"
	TestUpgradeInstance2 = "upgrade-instance2"
)
View Source
const (
	PodInvalid         = State("PodInvalid")
	PodTerminal        = State("PodTerminal")
	PodLabelMismatch   = State("PodLabelMismatch")
	NodeMissing        = State("NodeMissing")
	NodeNotFound       = State("NodeNotFound")
	ZoneMissing        = State("ZoneMissing")
	IPInvalid          = State("IPInvalid")
	IPNotFromPod       = State("IPNotFromPod")
	IPOutOfPodCIDR     = State("IPOutOfPodCIDR")
	OtherError         = State("OtherError")
	Duplicate          = State("Duplicate")
	DualStackMigration = State("DualStackMigration") // Total number of endpoints which require migration.
	Total              = State("Total")
)
View Source
const (
	ReasonEPCountsDiffer            = Reason("EPCountsDiffer")
	ReasonEPNodeMissing             = Reason("EPNodeMissing")
	ReasonEPNodeNotFound            = Reason("EPNodeNotFound")
	ReasonEPNodeTypeAssertionFailed = Reason("EPNodeTypeAssertionFailed")
	ReasonEPPodMissing              = Reason("EPPodMissing")
	ReasonEPPodNotFound             = Reason("EPPodNotFound")
	ReasonEPPodTypeAssertionFailed  = Reason("EPPodTypeAssertionFailed")
	ReasonEPPodTerminal             = Reason("EPPodTerminal")
	ReasonEPZoneMissing             = Reason("EPZoneMissing")
	ReasonEPSEndpointCountZero      = Reason("EPSEndpointCountZero")
	ReasonEPCalculationCountZero    = Reason("EPCalculationCountZero")
	ReasonInvalidAPIResponse        = Reason("InvalidAPIResponse")
	ReasonInvalidEPAttach           = Reason("InvalidEPAttach")
	ReasonInvalidEPDetach           = Reason("InvalidEPDetach")
	ReasonEPIPInvalid               = Reason("EPIPInvalid")
	ReasonEPIPNotFromPod            = Reason("EPIPNotFromPod")
	ReasonEPIPOutOfPodCIDR          = Reason("EPIPOutOfPodCIDR")
	ReasonEPServiceNotFound         = Reason("EPServiceNotFound")
	ReasonEPPodLabelMismatch        = Reason("EPPodLabelMismatch")

	// these are for non error-state error
	ReasonNegNotFound          = Reason("NegNotFound")
	ReasonCurrentNegEPNotFound = Reason("CurrentNegEPNotFound")
	ReasonEPSNotFound          = Reason("EPSNotFound")
	ReasonOtherError           = Reason("OtherError")
	ReasonSuccess              = Reason("Success")
)
View Source
const (
	VmIpPortEndpointType      = NetworkEndpointType("GCE_VM_IP_PORT")
	VmIpEndpointType          = NetworkEndpointType("GCE_VM_IP")
	NonGCPPrivateEndpointType = NetworkEndpointType("NON_GCP_PRIVATE_IP_PORT")
	L7Mode                    = EndpointsCalculatorMode("L7")
	L4LocalMode               = EndpointsCalculatorMode("L4, ExternalTrafficPolicy:Local")
	L4ClusterMode             = EndpointsCalculatorMode("L4, ExternalTrafficPolicy:Cluster")

	NegCRManagedByKey   = "networking.gke.io/managed-by"
	NegCRServiceNameKey = "networking.gke.io/service-name"
	NegCRServicePortKey = "networking.gke.io/service-port"
	// NegCRControllerValue is used as the value for the managed-by label on NEG CRs when enabled.
	NegCRControllerValue = "neg-controller"

	// NEG CR Condition Reasons
	NegSyncSuccessful           = "NegSyncSuccessful"
	NegSyncFailed               = "NegSyncFailed"
	NegInitializationSuccessful = "NegInitializationSuccessful"
	NegInitializationFailed     = "NegInitializationFailed"

	// NEG CRD Enabled Garbage Collection Event Reasons
	NegGCError = "NegCRError"
)

Variables

View Source
var (
	ErrEPCountsDiffer = NegSyncError{
		Err:          errors.New("endpoint counts from endpointData and endpointPodMap should be equal"),
		Reason:       ReasonEPCountsDiffer,
		IsErrorState: true,
	}
	ErrEPNodeMissing = NegSyncError{
		Err:          errors.New("endpoint has missing nodeName field"),
		Reason:       ReasonEPNodeMissing,
		IsErrorState: true,
	}
	ErrEPNodeNotFound = NegSyncError{
		Err:          errors.New("endpoint corresponds to an non-existing node"),
		Reason:       ReasonEPNodeNotFound,
		IsErrorState: true,
	}
	ErrEPNodeTypeAssertionFailed = NegSyncError{
		Err:          errors.New("endpoint corresponds to an object that fails node type assertion"),
		Reason:       ReasonEPNodeTypeAssertionFailed,
		IsErrorState: true,
	}
	ErrEPPodMissing = NegSyncError{
		Err:          errors.New("endpoint has missing pod field"),
		Reason:       ReasonEPPodMissing,
		IsErrorState: true,
	}
	ErrEPPodNotFound = NegSyncError{
		Err:          errors.New("endpoint corresponds to an non-existing pod"),
		Reason:       ReasonEPPodNotFound,
		IsErrorState: true,
	}
	ErrEPPodTypeAssertionFailed = NegSyncError{
		Err:          errors.New("endpoint corresponds to an object that fails pod type assertion"),
		Reason:       ReasonEPPodTypeAssertionFailed,
		IsErrorState: true,
	}
	ErrEPPodTerminal = NegSyncError{
		Err:          errors.New("endpoint corresponds to a terminal pod"),
		Reason:       ReasonEPPodTerminal,
		IsErrorState: true,
	}
	ErrEPZoneMissing = NegSyncError{
		Err:          errors.New("endpoint has missing zone field"),
		Reason:       ReasonEPZoneMissing,
		IsErrorState: true,
	}
	ErrEPSEndpointCountZero = NegSyncError{
		Err:          errors.New("endpoint count from endpointData cannot be zero"),
		Reason:       ReasonEPSEndpointCountZero,
		IsErrorState: true,
	}
	ErrEPCalculationCountZero = NegSyncError{
		Err:          errors.New("endpoint count from endpointPodMap cannot be zero"),
		Reason:       ReasonEPCalculationCountZero,
		IsErrorState: true,
	}
	ErrInvalidAPIResponse = NegSyncError{
		Err:          errors.New("received response error doesn't match googleapi.Error type"),
		Reason:       ReasonInvalidAPIResponse,
		IsErrorState: true,
	}
	ErrInvalidEPAttach = NegSyncError{
		Err:          errors.New("endpoint information for attach operation is incorrect"),
		Reason:       ReasonInvalidEPAttach,
		IsErrorState: true,
	}
	ErrInvalidEPDetach = NegSyncError{
		Err:          errors.New("endpoint information for detach operation is incorrect"),
		Reason:       ReasonInvalidEPDetach,
		IsErrorState: true,
	}
	ErrEPIPInvalid = NegSyncError{
		Err:          errors.New("endpoint has an invalid IP address"),
		Reason:       ReasonEPIPInvalid,
		IsErrorState: true,
	}
	ErrEPIPNotFromPod = NegSyncError{
		Err:          errors.New("endpoint has an IP that does not correspond to its pod"),
		Reason:       ReasonEPIPNotFromPod,
		IsErrorState: true,
	}
	ErrEPIPOutOfPodCIDR = NegSyncError{
		Err:          errors.New("endpoint corresponds to a pod with IP out of PodCIDR range"),
		Reason:       ReasonEPIPOutOfPodCIDR,
		IsErrorState: true,
	}
	ErrEPServiceNotFound = NegSyncError{
		Err:          errors.New("endpoint corresponds to a non-existent service"),
		Reason:       ReasonEPServiceNotFound,
		IsErrorState: true,
	}
	ErrEPPodLabelMismatch = NegSyncError{
		Err:          errors.New("endpoint corresponds to a pod with labels not matching to its service"),
		Reason:       ReasonEPPodLabelMismatch,
		IsErrorState: true,
	}

	ErrNegNotFound = NegSyncError{
		Err:          errors.New("failed to get NEG for service"),
		Reason:       ReasonNegNotFound,
		IsErrorState: false,
	}
	ErrCurrentNegEPNotFound = NegSyncError{
		Err:          errors.New("failed to get current NEG endpoints"),
		Reason:       ReasonCurrentNegEPNotFound,
		IsErrorState: false,
	}
	ErrEPSNotFound = NegSyncError{
		Err:          errors.New("failed to get EPS for service"),
		Reason:       ReasonEPSNotFound,
		IsErrorState: false,
	}
)

Functions

func IsStrategyQuotaError added in v1.24.0

func IsStrategyQuotaError(err error) bool

IsStrategyQuotaError takes an error and checks if this error is a StrategyQuotaError

func MockAggregatedListNetworkEndpointGroupHook added in v1.7.0

func MockAggregatedListNetworkEndpointGroupHook(ctx context.Context, fl *filter.F, m *cloud.MockNetworkEndpointGroups) (bool, map[string][]*compute.NetworkEndpointGroup, error)

TODO: move this logic into code gen TODO: make AggregateList return map[meta.Key]Object

func MockAttachNetworkEndpointsHook added in v1.5.0

func MockAttachNetworkEndpointsHook(ctx context.Context, key *meta.Key, obj *compute.NetworkEndpointGroupsAttachEndpointsRequest, m *cloud.MockNetworkEndpointGroups) error

func MockDetachNetworkEndpointsHook added in v1.5.0

func MockDetachNetworkEndpointsHook(ctx context.Context, key *meta.Key, obj *compute.NetworkEndpointGroupsDetachEndpointsRequest, m *cloud.MockNetworkEndpointGroups) error

func MockListNetworkEndpointsHook added in v1.5.0

func MockListNetworkEndpointsHook(ctx context.Context, key *meta.Key, obj *compute.NetworkEndpointGroupsListEndpointsRequest, filter *filter.F, m *cloud.MockNetworkEndpointGroups) ([]*compute.NetworkEndpointWithHealthStatus, error)

func MockNetworkEndpointAPIs added in v1.5.0

func MockNetworkEndpointAPIs(fakeGCE *gce.Cloud)

func NodePredicateForEndpointCalculatorMode added in v1.14.0

func NodePredicateForEndpointCalculatorMode(mode EndpointsCalculatorMode) utils.NodeConditionPredicate

NodePredicateForEndpointCalculatorMode returns the predicate function to select candidate nodes, given the endpoints calculator mode.

func NodePredicateForNetworkEndpointType added in v1.20.0

func NodePredicateForNetworkEndpointType(negType NetworkEndpointType) utils.NodeConditionPredicate

NodePredicateForNetworkEndpointType returns the predicate function to select candidate nodes, given the NEG type.

Types

type AddressData added in v1.14.0

type AddressData struct {
	TargetRef   *apiv1.ObjectReference
	NodeName    *string
	Addresses   []string
	Ready       bool
	AddressType discovery.AddressType
}

type EndpointPodMap added in v1.6.0

type EndpointPodMap map[NetworkEndpoint]types.NamespacedName

EndpointPodMap is a map from network endpoint to a namespaced name of a pod

type EndpointsCalculatorMode added in v1.9.0

type EndpointsCalculatorMode string

type EndpointsData added in v1.14.0

type EndpointsData struct {
	Meta  *metav1.ObjectMeta
	Ports []PortData
	// Addresses contains both ready and not ready addresses even when it is converted from Endpoints.
	Addresses []AddressData
}

Abstraction over Endpoints and EndpointSlices. It contains all the information needed to set up GCP Load Balancer.

func EndpointsDataFromEndpointSlices added in v1.14.0

func EndpointsDataFromEndpointSlices(slices []*discovery.EndpointSlice) []EndpointsData

Converts API EndpointSlice list to the EndpointsData abstraction. Terminating endpoints are ignored.

type FakeNetworkEndpointGroupCloud

type FakeNetworkEndpointGroupCloud struct {
	NetworkEndpointGroups map[string][]*composite.NetworkEndpointGroup
	NetworkEndpoints      map[string][]*composite.NetworkEndpoint
	Subnetwork            string
	Network               string
	// contains filtered or unexported fields
}

func (*FakeNetworkEndpointGroupCloud) AggregatedListNetworkEndpointGroup

func (f *FakeNetworkEndpointGroupCloud) AggregatedListNetworkEndpointGroup(version meta.Version, _ klog.Logger) (map[*meta.Key]*composite.NetworkEndpointGroup, error)

func (*FakeNetworkEndpointGroupCloud) AttachNetworkEndpoints

func (f *FakeNetworkEndpointGroupCloud) AttachNetworkEndpoints(name, zone string, endpoints []*composite.NetworkEndpoint, version meta.Version, _ klog.Logger) error

func (*FakeNetworkEndpointGroupCloud) CreateNetworkEndpointGroup

func (f *FakeNetworkEndpointGroupCloud) CreateNetworkEndpointGroup(neg *composite.NetworkEndpointGroup, zone string, _ klog.Logger) error

func (*FakeNetworkEndpointGroupCloud) DeleteNetworkEndpointGroup

func (f *FakeNetworkEndpointGroupCloud) DeleteNetworkEndpointGroup(name string, zone string, version meta.Version, _ klog.Logger) error

func (*FakeNetworkEndpointGroupCloud) DetachNetworkEndpoints

func (f *FakeNetworkEndpointGroupCloud) DetachNetworkEndpoints(name, zone string, endpoints []*composite.NetworkEndpoint, version meta.Version, _ klog.Logger) error

func (*FakeNetworkEndpointGroupCloud) GetNetworkEndpointGroup

func (f *FakeNetworkEndpointGroupCloud) GetNetworkEndpointGroup(name string, zone string, version meta.Version, _ klog.Logger) (*composite.NetworkEndpointGroup, error)

func (*FakeNetworkEndpointGroupCloud) ListNetworkEndpointGroup

func (f *FakeNetworkEndpointGroupCloud) ListNetworkEndpointGroup(zone string, version meta.Version, _ klog.Logger) ([]*composite.NetworkEndpointGroup, error)

func (*FakeNetworkEndpointGroupCloud) ListNetworkEndpoints

func (f *FakeNetworkEndpointGroupCloud) ListNetworkEndpoints(name, zone string, showHealthStatus bool, version meta.Version, _ klog.Logger) ([]*composite.NetworkEndpointWithHealthStatus, error)

func (*FakeNetworkEndpointGroupCloud) NetworkProjectID added in v1.24.0

func (f *FakeNetworkEndpointGroupCloud) NetworkProjectID() string

func (*FakeNetworkEndpointGroupCloud) NetworkURL

func (f *FakeNetworkEndpointGroupCloud) NetworkURL() string

func (*FakeNetworkEndpointGroupCloud) Region added in v1.24.0

func (*FakeNetworkEndpointGroupCloud) SubnetworkURL

func (f *FakeNetworkEndpointGroupCloud) SubnetworkURL() string

type FakeZoneGetter added in v1.11.10

type FakeZoneGetter struct {
	// contains filtered or unexported fields
}

func NewFakeZoneGetter

func NewFakeZoneGetter() *FakeZoneGetter

func (*FakeZoneGetter) AddZone added in v1.11.10

func (f *FakeZoneGetter) AddZone(newZone string, instances ...string) error

Adds a zone with the given instances to the zone getter

func (*FakeZoneGetter) DeleteZone added in v1.11.10

func (f *FakeZoneGetter) DeleteZone(newZone string)

Deletes a zone in the zoneInstanceMap

func (*FakeZoneGetter) GetZoneForNode added in v1.11.10

func (f *FakeZoneGetter) GetZoneForNode(name string) (string, error)

func (*FakeZoneGetter) ListZones added in v1.11.10

func (f *FakeZoneGetter) ListZones(predicate utils.NodeConditionPredicate) ([]string, error)

type NegSyncError added in v1.24.0

type NegSyncError struct {
	Err          error
	Reason       Reason
	IsErrorState bool
}

other errors encountered during sync are considered as OtherError in metrics and they will not trigger error state if any errors need to be collected in sync metrics or used to set error state, please define them above

func ClassifyError added in v1.24.0

func ClassifyError(err error) NegSyncError

ClassifyError takes an error and checks if this error is a NegSyncError if so, it unwraps and returns the NegSyncError, else it would wrap it as a NegSyncError with ReasonOtherError and IsErrorState set to false

func (NegSyncError) Error added in v1.24.0

func (se NegSyncError) Error() string

type NegSyncer

type NegSyncer interface {
	// Start starts the syncer. This call is synchronous. It will return after syncer is started.
	Start() error
	// Stop stops the syncer. This call is asynchronous. It will not block until syncer is stopped.
	Stop()
	// Sync signals the syncer to sync NEG. This call is asynchronous. Syncer will sync once it becomes idle.
	Sync() bool
	// IsStopped returns true if syncer is stopped
	IsStopped() bool
	// IsShuttingDown returns true if syncer is shutting down
	IsShuttingDown() bool
}

NegSyncer is an interface to interact with syncer

type NegSyncerKey added in v1.6.0

type NegSyncerKey struct {
	// Namespace of service
	Namespace string
	// Name of service
	Name string
	// Name of neg
	NegName string
	// PortTuple is the port tuple of the service backing the NEG
	PortTuple SvcPortTuple

	// NegType is the type of the network endpoints in this NEG.
	NegType NetworkEndpointType

	// EpCalculatorMode indicates how the endpoints for the NEG are determined.
	// GCE_VM_IP_PORT NEGs get L7Mode or "".
	// In case of GCE_VM_IP NEGs:
	//   The endpoints are nodes selected at random in case of Cluster trafficPolicy(L4ClusterMode).
	//   The endpoints are nodes running backends of this service in case of Local trafficPolicy(L4LocalMode).
	EpCalculatorMode EndpointsCalculatorMode
}

NegSyncerKey includes information to uniquely identify a NEG syncer

func (NegSyncerKey) GetAPIVersion added in v1.8.0

func (key NegSyncerKey) GetAPIVersion() meta.Version

GetAPIVersion returns the compute API version to be used in order to create the negType specified in the given NegSyncerKey.

func (NegSyncerKey) String added in v1.6.0

func (key NegSyncerKey) String() string

type NegSyncerManager

type NegSyncerManager interface {
	// EnsureSyncer ensures corresponding syncers are started and stops any unnecessary syncer
	// portMap is a map of ServicePort Port to TargetPort. Returns counts of successful Neg syncers
	// and failed Neg syncer creations
	EnsureSyncers(namespace, name string, portMap PortInfoMap) (int, int, error)
	// StopSyncer stops all syncers related to the service. This call is asynchronous. It will not wait for all syncers to stop.
	StopSyncer(namespace, name string)
	// Sync signals all syncers related to the service to sync. This call is asynchronous.
	Sync(namespace, name string)
	// SyncNodes signals all syncers watching nodes to sync. This call is asynchronous.
	SyncNodes()
	// GC garbage collects network endpoint group and syncers
	GC() error
	// ShutDown shuts down the manager
	ShutDown()
}

NegSyncerManager is an interface for controllers to manage syncer

type NetworkEndpoint added in v1.6.0

type NetworkEndpoint struct {
	IP   string
	IPv6 string
	Port string
	Node string
}

NetworkEndpoint contains the essential information for each network endpoint in a NEG

type NetworkEndpointEntry added in v1.5.0

type NetworkEndpointEntry struct {
	NetworkEndpoint *composite.NetworkEndpoint
	Healths         []*composite.HealthStatusForNetworkEndpoint
}

type NetworkEndpointGroupCloud

type NetworkEndpointGroupCloud interface {
	GetNetworkEndpointGroup(name string, zone string, version meta.Version, logger klog.Logger) (*composite.NetworkEndpointGroup, error)
	ListNetworkEndpointGroup(zone string, version meta.Version, logger klog.Logger) ([]*composite.NetworkEndpointGroup, error)
	AggregatedListNetworkEndpointGroup(version meta.Version, logger klog.Logger) (map[*meta.Key]*composite.NetworkEndpointGroup, error)
	CreateNetworkEndpointGroup(neg *composite.NetworkEndpointGroup, zone string, logger klog.Logger) error
	DeleteNetworkEndpointGroup(name string, zone string, version meta.Version, logger klog.Logger) error
	AttachNetworkEndpoints(name, zone string, endpoints []*composite.NetworkEndpoint, version meta.Version, logger klog.Logger) error
	DetachNetworkEndpoints(name, zone string, endpoints []*composite.NetworkEndpoint, version meta.Version, logger klog.Logger) error
	ListNetworkEndpoints(name, zone string, showHealthStatus bool, version meta.Version, logger klog.Logger) ([]*composite.NetworkEndpointWithHealthStatus, error)
	NetworkURL() string
	SubnetworkURL() string
	NetworkProjectID() string
	Region() string
}

NetworkEndpointGroupCloud is an interface for managing gce network endpoint group.

func NewAdapter added in v1.6.0

func NewAdapter(g *gce.Cloud) NetworkEndpointGroupCloud

NewAdapter takes a Cloud and returns a NetworkEndpointGroupCloud.

func NewAdapterWithNetwork added in v1.10.8

func NewAdapterWithNetwork(g *gce.Cloud, network, subnetwork string) NetworkEndpointGroupCloud

func NewAdapterWithRateLimitSpecs added in v1.24.0

func NewAdapterWithRateLimitSpecs(g *gce.Cloud, specs []string) NetworkEndpointGroupCloud

NewAdapterWithRateLimitSpecs takes a cloud and rate limit specs and returns a NetworkEndpointGroupCloud.

func NewFakeNetworkEndpointGroupCloud

func NewFakeNetworkEndpointGroupCloud(subnetwork, network string) NetworkEndpointGroupCloud

DEPRECATED: Please do not use this mock function. Use the pkg/neg/types/mock.go instead.

type NetworkEndpointGroupNamer

type NetworkEndpointGroupNamer interface {
	NEG(namespace, name string, port int32) string
	IsNEG(name string) bool
}

NetworkEndpointGroupNamer is an interface for generating network endpoint group name.

type NetworkEndpointSet added in v1.6.0

type NetworkEndpointSet map[NetworkEndpoint]struct{}

NetworkEndpointSet is a set of NetworkEndpoints, implemented via map[NetworkEndpoint]struct{} for minimal memory consumption.

func NetworkEndpointSetKeySet added in v1.6.0

func NetworkEndpointSetKeySet(theMap interface{}) NetworkEndpointSet

NetworkEndpointSetKeySet creates a NetworkEndpointSet from a keys of a map[NetworkEndpoint](? extends interface{}). If the value passed in is not actually a map, this will panic.

func NewNetworkEndpointSet added in v1.6.0

func NewNetworkEndpointSet(items ...NetworkEndpoint) NetworkEndpointSet

NewNetworkEndpointSet creates a NetworkEndpointSet from a list of values.

func (NetworkEndpointSet) Delete added in v1.6.0

func (s NetworkEndpointSet) Delete(items ...NetworkEndpoint)

Delete removes all items from the set.

func (NetworkEndpointSet) Difference added in v1.6.0

Difference returns a set of objects that are not in s2 For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}

func (NetworkEndpointSet) Equal added in v1.6.0

Equal returns true if and only if s1 is equal (as a set) to s2. Two sets are equal if their membership is identical. (In practice, this means same elements, order doesn't matter)

func (NetworkEndpointSet) Has added in v1.6.0

Has returns true if and only if item is contained in the set.

func (NetworkEndpointSet) HasAll added in v1.6.0

func (s NetworkEndpointSet) HasAll(items ...NetworkEndpoint) bool

HasAll returns true if and only if all items are contained in the set.

func (NetworkEndpointSet) HasAny added in v1.6.0

func (s NetworkEndpointSet) HasAny(items ...NetworkEndpoint) bool

HasAny returns true if any items are contained in the set.

func (NetworkEndpointSet) Insert added in v1.6.0

func (s NetworkEndpointSet) Insert(items ...NetworkEndpoint)

Insert adds items to the set.

func (NetworkEndpointSet) Intersection added in v1.6.0

Intersection returns a new set which includes the item in BOTH s1 and s2 For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}

func (NetworkEndpointSet) IsSuperset added in v1.6.0

func (s1 NetworkEndpointSet) IsSuperset(s2 NetworkEndpointSet) bool

IsSuperset returns true if and only if s1 is a superset of s2.

func (NetworkEndpointSet) Len added in v1.6.0

func (s NetworkEndpointSet) Len() int

Len returns the size of the set.

func (NetworkEndpointSet) List added in v1.6.0

List returns the slice with contents in random order.

func (NetworkEndpointSet) PopAny added in v1.6.0

func (s NetworkEndpointSet) PopAny() (NetworkEndpoint, bool)

PopAny returns a single element from the set.

func (NetworkEndpointSet) Union added in v1.6.0

Union returns a new set which includes items in either s1 or s2. For example: s1 = {a1, a2} s2 = {a3, a4} s1.Union(s2) = {a1, a2, a3, a4} s2.Union(s1) = {a1, a2, a3, a4}

type NetworkEndpointStore added in v1.5.0

type NetworkEndpointStore map[meta.Key][]NetworkEndpointEntry

func GetNetworkEndpointStore added in v1.7.0

func GetNetworkEndpointStore(negCloud NetworkEndpointGroupCloud) NetworkEndpointStore

GetNetworkEndpointStore is a helper function to access the NetworkEndpointStore of the mock NEG cloud

func (NetworkEndpointStore) AddNetworkEndpointHealthStatus added in v1.7.0

func (s NetworkEndpointStore) AddNetworkEndpointHealthStatus(key meta.Key, entries []NetworkEndpointEntry)

type NetworkEndpointType added in v1.8.0

type NetworkEndpointType string

type NetworkEndpointsCalculator added in v1.9.0

type NetworkEndpointsCalculator interface {
	// CalculateEndpoints computes the NEG endpoints based on service endpoints and the current NEG state and returns a
	// map of zone name to network endpoint set
	CalculateEndpoints(eds []EndpointsData, currentMap map[string]NetworkEndpointSet) (map[string]NetworkEndpointSet, EndpointPodMap, int, error)
	// CalculateEndpointsDegradedMode computes the NEG endpoints using degraded mode calculation
	CalculateEndpointsDegradedMode(eds []EndpointsData, currentMap map[string]NetworkEndpointSet) (map[string]NetworkEndpointSet, EndpointPodMap, error)
	// Mode indicates the mode that the EndpointsCalculator is operating in.
	Mode() EndpointsCalculatorMode
	// ValidateEndpoints validates the NEG endpoint information is correct
	ValidateEndpoints(endpointData []EndpointsData, endpointPodMap EndpointPodMap, dupCount int) error
}

type PortData added in v1.14.0

type PortData struct {
	Name string
	Port int32
}

type PortInfo added in v1.6.0

type PortInfo struct {
	// PortTuple is port tuple of a service.
	PortTuple SvcPortTuple

	// NegName is the name of the NEG
	NegName string
	// ReadinessGate indicates if the NEG associated with the port has NEG readiness gate enabled
	// This is enabled with service port is reference by ingress.
	// If the service port is only exposed as stand alone NEG, it should not be enabled.
	ReadinessGate bool
	// EpCalculatorMode indicates if the endpoints for the NEG associated with this port need to
	// be selected at random(L4ClusterMode), or by following service endpoints(L4LocalMode).
	// This is applicable in GCE_VM_IP NEGs where the endpoints are the nodes instead of pods.
	// L7 NEGs will have either "" or L7Mode.
	EpCalculatorMode EndpointsCalculatorMode
	// NetworkInfo specifies the network (K8s and VPC) and subnetwork the service port belongs to.
	NetworkInfo network.NetworkInfo
}

PortInfo contains information associated with service port

type PortInfoMap added in v1.6.0

type PortInfoMap map[PortInfoMapKey]PortInfo

PortInfoMap is a map of PortInfoMapKey:PortInfo

func NewPortInfoMap added in v1.6.0

func NewPortInfoMap(namespace, name string, svcPortTupleSet SvcPortTupleSet, namer NetworkEndpointGroupNamer, readinessGate bool, customNegNames map[SvcPortTuple]string, networkInfo *network.NetworkInfo) PortInfoMap

func NewPortInfoMapForVMIPNEG added in v1.9.4

func NewPortInfoMapForVMIPNEG(namespace, name string, namer namer.L4ResourcesNamer, local bool, networkInfo *network.NetworkInfo) PortInfoMap

NewPortInfoMapForVMIPNEG creates PortInfoMap with empty port tuple. Since VM_IP NEGs target the node instead of the pod, there is no port info to be stored.

func (PortInfoMap) Difference added in v1.6.0

func (p1 PortInfoMap) Difference(p2 PortInfoMap) PortInfoMap

Difference returns the entries of PortInfoMap which satisfies one of the following 2 conditions: 1. portInfo entry is in p1 and not present in p2 2. or the portInfo entry is not the same in p1 and p2.

func (PortInfoMap) EndpointsCalculatorMode added in v1.14.0

func (p1 PortInfoMap) EndpointsCalculatorMode() EndpointsCalculatorMode

EndpointsCalculatorMode returns the endpoints calculator mode for this portInfoMap. This indicates the type of NEG used.

func (PortInfoMap) Merge added in v1.6.0

func (p1 PortInfoMap) Merge(p2 PortInfoMap) error

Merge merges p2 into p1 PortInfoMap It assumes the same key (service port) will have the same target port and negName If not, it will throw error If a key in p1 or p2 has readiness gate enabled, the merged port info will also has readiness gate enabled The merged port info will have the same Endpoints Calculator mode as p1 and p2. This field is important for VM_IP NEGs. L7 NEGs can have an empty string or L7Mode value.

func (PortInfoMap) NegsWithReadinessGate added in v1.6.0

func (p1 PortInfoMap) NegsWithReadinessGate() sets.String

NegsWithReadinessGate returns the NegNames which has readiness gate enabled

func (PortInfoMap) ToPortNegMap added in v1.6.0

func (p1 PortInfoMap) ToPortNegMap() annotations.PortNegMap

type PortInfoMapKey added in v1.7.0

type PortInfoMapKey struct {
	// ServicePort is the service port
	ServicePort int32
}

PortInfoMapKey is the Key of PortInfoMap

type Reason added in v1.24.0

type Reason string

type State added in v1.23.0

type State string

func StatesForEndpointMetrics added in v1.24.0

func StatesForEndpointMetrics() []State

StatesForEndpointMetrics gets all states for endpoint and endpoint slice

type StateCountMap added in v1.23.0

type StateCountMap map[State]int

StateCountMap collect the count of instances in different states

type StrategyQuotaError added in v1.24.0

type StrategyQuotaError struct {
	Err error
}

StrategyQuotaError indicates that a quota error was a result of a request using throttling.Strategy.

func (StrategyQuotaError) Error added in v1.24.0

func (e StrategyQuotaError) Error() string

type SvcPortTuple added in v1.8.0

type SvcPortTuple struct {
	// Port is the service port number
	Port int32
	// Name is the service port name
	Name string
	// TargetPort is the service target port.
	// This can be a port number or named port
	TargetPort string
}

SvcPortTuple is the tuple representing one service port

func (SvcPortTuple) Empty added in v1.9.0

func (t SvcPortTuple) Empty() bool

func (SvcPortTuple) String added in v1.8.0

func (t SvcPortTuple) String() string

String returns the string representation of SvcPortTuple

type SvcPortTupleSet added in v1.8.0

type SvcPortTupleSet map[SvcPortTuple]struct{}

SvcPortTupleSet is a set of SvcPortTuple

func NewSvcPortTupleSet added in v1.8.0

func NewSvcPortTupleSet(tuples ...SvcPortTuple) SvcPortTupleSet

NewSvcPortTupleSet returns SvcPortTupleSet with the input tuples

func (SvcPortTupleSet) Get added in v1.8.0

func (set SvcPortTupleSet) Get(svcPort int32) (SvcPortTuple, bool)

Get returns the SvcPortTuple with matching svc port if found

func (SvcPortTupleSet) Insert added in v1.8.0

func (set SvcPortTupleSet) Insert(tuples ...SvcPortTuple)

Insert inserts a SvcPortTuple into SvcPortTupleSet

type TestContext added in v1.11.0

type TestContext struct {
	KubeClient   kubernetes.Interface
	SvcNegClient svcnegclient.Interface
	Cloud        *gce.Cloud

	NegNamer NetworkEndpointGroupNamer
	L4Namer  namer.L4ResourcesNamer

	IngressInformer            cache.SharedIndexInformer
	PodInformer                cache.SharedIndexInformer
	ServiceInformer            cache.SharedIndexInformer
	NodeInformer               cache.SharedIndexInformer
	EndpointInformer           cache.SharedIndexInformer
	EndpointSliceInformer      cache.SharedIndexInformer
	SvcNegInformer             cache.SharedIndexInformer
	NetworkInformer            cache.SharedIndexInformer
	GKENetworkParamSetInformer cache.SharedIndexInformer

	KubeSystemUID      types.UID
	ResyncPeriod       time.Duration
	NumGCWorkers       int
	EnableDualStackNEG bool
}

TestContext provides controller context for testing

func NewTestContext added in v1.11.0

func NewTestContext() *TestContext

func NewTestContextWithKubeClient added in v1.11.0

func NewTestContextWithKubeClient(kubeClient kubernetes.Interface) *TestContext

type ZoneGetter

type ZoneGetter interface {
	ListZones(predicate utils.NodeConditionPredicate) ([]string, error)
	GetZoneForNode(name string) (string, error)
}

ZoneGetter is an interface for retrieve zone related information

func NewSimpleZoneGetter added in v1.10.0

func NewSimpleZoneGetter(zone string) ZoneGetter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL