types

package
v1.10.14 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TestZone1     = "zone1"
	TestZone2     = "zone2"
	TestInstance1 = "instance1"
	TestInstance2 = "instance2"
	TestInstance3 = "instance3"
	TestInstance4 = "instance4"
	TestInstance5 = "instance5"
	TestInstance6 = "instance6"
)
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

Functions

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 MockBetaAggregatedListNetworkEndpointGroupHook added in v1.10.12

func MockBetaAggregatedListNetworkEndpointGroupHook(ctx context.Context, fl *filter.F, m *cloud.MockBetaNetworkEndpointGroups) (bool, map[string][]*computebeta.NetworkEndpointGroup, 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 NewFakeZoneGetter

func NewFakeZoneGetter() *fakeZoneGetter

Types

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 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) (map[*meta.Key]*composite.NetworkEndpointGroup, error)

func (*FakeNetworkEndpointGroupCloud) AttachNetworkEndpoints

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

func (*FakeNetworkEndpointGroupCloud) CreateNetworkEndpointGroup

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

func (*FakeNetworkEndpointGroupCloud) DeleteNetworkEndpointGroup

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

func (*FakeNetworkEndpointGroupCloud) DetachNetworkEndpoints

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

func (*FakeNetworkEndpointGroupCloud) GetNetworkEndpointGroup

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

func (*FakeNetworkEndpointGroupCloud) ListNetworkEndpointGroup

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

func (*FakeNetworkEndpointGroupCloud) ListNetworkEndpoints

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

func (*FakeNetworkEndpointGroupCloud) NetworkURL

func (f *FakeNetworkEndpointGroupCloud) NetworkURL() string

func (*FakeNetworkEndpointGroupCloud) SubnetworkURL

func (f *FakeNetworkEndpointGroupCloud) SubnetworkURL() 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

	// Subset name, subset is defined in Istio:DestinationRule, this is only used
	// when --enable-csm=true.
	Subset string

	// Subset label, should set together with Subset.
	SubsetLabels string

	// 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
	EnsureSyncers(namespace, name string, portMap PortInfoMap) 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
	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) (*composite.NetworkEndpointGroup, error)
	ListNetworkEndpointGroup(zone string, version meta.Version) ([]*composite.NetworkEndpointGroup, error)
	AggregatedListNetworkEndpointGroup(version meta.Version) (map[*meta.Key]*composite.NetworkEndpointGroup, error)
	CreateNetworkEndpointGroup(neg *composite.NetworkEndpointGroup, zone string) error
	DeleteNetworkEndpointGroup(name string, zone string, version meta.Version) error
	AttachNetworkEndpoints(name, zone string, endpoints []*composite.NetworkEndpoint, version meta.Version) error
	DetachNetworkEndpoints(name, zone string, endpoints []*composite.NetworkEndpoint, version meta.Version) error
	ListNetworkEndpoints(name, zone string, showHealthStatus bool, version meta.Version) ([]*composite.NetworkEndpointWithHealthStatus, error)
	NetworkURL() string
	SubnetworkURL() 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 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
	VMIPNEG(namespace, name string) (string, bool)
	NEGWithSubset(namespace, name, subset 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(ep *v1.Endpoints, currentMap map[string]NetworkEndpointSet) (map[string]NetworkEndpointSet, EndpointPodMap, error)
	// Mode indicates the mode that the EndpointsCalculator is operating in.
	Mode() EndpointsCalculatorMode
}

type PortInfo added in v1.6.0

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

	// Subset name, subset is defined in Istio:DestinationRule, this is only used
	// when --enable-csm=true.
	Subset string

	// Subset label, should set together with Subset.
	SubsetLabels string

	// 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 enbled.
	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
}

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) PortInfoMap

func NewPortInfoMapForVMIPNEG added in v1.9.4

func NewPortInfoMapForVMIPNEG(namespace, name string, namer namer.L4ResourcesNamer, local bool) 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 NewPortInfoMapWithDestinationRule added in v1.7.0

func NewPortInfoMapWithDestinationRule(namespace, name string, svcPortTupleSet SvcPortTupleSet, namer NetworkEndpointGroupNamer, readinessGate bool,
	destinationRule *istioV1alpha3.DestinationRule) (PortInfoMap, error)

NewPortInfoMapWithDestinationRule create PortInfoMap based on a gaven DesinationRule. Return error message if the DestinationRule contains duplicated subsets.

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) 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

func (PortInfoMap) ToPortSubsetNegMap added in v1.7.0

func (p1 PortInfoMap) ToPortSubsetNegMap() annotations.PortSubsetNegMap

type PortInfoMapKey added in v1.7.0

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

	// Istio:DestinationRule Subset, only used when --enable-csm=true
	Subset string
}

PortInfoMapKey is the Key of PortInfoMap

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 ZoneGetter

type ZoneGetter interface {
	ListZones() ([]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