common

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AntreaMCServiceAnnotation = "multicluster.antrea.io/imported-service"
	AntreaMCACNPAnnotation    = "multicluster.antrea.io/imported-acnp"
	GatewayAnnotation         = "multicluster.antrea.io/gateway"
	GatewayIPAnnotation       = "multicluster.antrea.io/gateway-ip"

	AntreaMCSPrefix = "antrea-mc-"

	InvalidClusterID    = ClusterID("invalid")
	InvalidClusterSetID = ClusterSetID("invalid")

	DefaultWorkerCount = 5
	// LabelIdentityWorkerCount is the number of workers used by LabelIdentityReconciler,
	// LabelIdentityExportReconciler and LabelIdentityResourceImportReconciler.
	// Using more workers for those reconcilers could have a better performance when a
	// lot of LabelIdentity events happen concurrently.
	LabelIdentityWorkerCount = 10

	EndpointIPTypeClusterIP = "ClusterIP"
	EndpointIPTypePodIP     = "PodIP"

	// ResourceExchangeQPS and ResourceExchangeBurst are used to configure the client-go
	// used by Antrea Multi-cluster resource exchange pipeline. Using higher QPS and
	// Burst, instead of default settings, could significantly improve the performance,
	// when a lot of LabelIdentity events happen concurrently.
	ResourceExchangeQPS   = 100
	ResourceExchangeBurst = 200
)

Variables

View Source
var (
	LocalClusterID  = "cluster-a"
	LeaderNamespace = "default"

	SvcPort80 = corev1.ServicePort{
		Name:     "http",
		Protocol: corev1.ProtocolTCP,
		Port:     80,
	}
	SvcPort8080 = corev1.ServicePort{
		Name:     "http",
		Protocol: corev1.ProtocolTCP,
		Port:     8080,
	}
	SvcNginxSpec = corev1.ServiceSpec{
		ClusterIP:  "192.168.2.3",
		ClusterIPs: []string{"192.168.2.3"},
		Ports: []corev1.ServicePort{
			SvcPort80,
		},
		Type: corev1.ServiceTypeClusterIP,
	}
	SvcNginx = &corev1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "nginx",
			Namespace: "default",
		},
		Spec: SvcNginxSpec,
	}

	EPPorts80 = []corev1.EndpointPort{
		{
			Name:     "http",
			Port:     80,
			Protocol: corev1.ProtocolTCP,
		},
	}
	EPNginxSubset = []corev1.EndpointSubset{
		{
			Addresses: []corev1.EndpointAddress{
				addr1,
			},
			Ports: EPPorts80,
		},
	}
	EPNginxSubset2 = []corev1.EndpointSubset{
		{
			Addresses: []corev1.EndpointAddress{
				addr2,
			},
			Ports: EPPorts80,
		},
	}
	EPNginx = &corev1.Endpoints{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "nginx",
			Namespace: "default",
		},
		Subsets: EPNginxSubset,
	}

	TestCtx    = context.Background()
	TestScheme = runtime.NewScheme()
)
View Source
var CleanUpRetry = wait.Backoff{
	Steps:    12,
	Duration: 500 * time.Millisecond,
	Factor:   2.0,
	Jitter:   1,
}

CleanUpRetry is the retry when the clean up method failed to clean up all stale resources.

Functions

func DiscoverServiceCIDRByInvalidServiceCreation added in v1.11.0

func DiscoverServiceCIDRByInvalidServiceCreation(ctx context.Context, k8sClient client.Client, namespace string) (string, error)

DiscoverServiceCIDRByInvalidServiceCreation creates an invalid Service to get returned error, and analyzes the error message to get Service CIDR. TODO: add dual-stack support.

func GetServiceEndpointPorts added in v1.7.0

func GetServiceEndpointPorts(ports []corev1.ServicePort) []corev1.EndpointPort

GetServiceEndpointPorts converts Service's port to EndpointPort

func GetServiceEndpointSubset added in v1.7.0

func GetServiceEndpointSubset(svc *corev1.Service) corev1.EndpointSubset

func HashLabelIdentity added in v1.9.0

func HashLabelIdentity(l string) string

HashLabelIdentity generates a hash value for label identity string.

func IsMulticlusterService added in v1.11.0

func IsMulticlusterService(service *corev1.Service) bool

func NamespacedName

func NamespacedName(namespace, name string) string

TODO: Use NamespacedName stringer method instead of this. e.g. nsName.String()

func NewClusterInfoResourceExportName added in v1.11.0

func NewClusterInfoResourceExportName(clusterID string) string

func RemoveStringFromSlice

func RemoveStringFromSlice(slice []string, s string) (result []string)

func StringExistsInSlice

func StringExistsInSlice(slice []string, s string) bool

func ToMCResourceName added in v1.10.0

func ToMCResourceName(originalResourceName string) string

Types

type ClusterID

type ClusterID string

func GetClusterID added in v1.13.0

func GetClusterID(clusterCalimCRDAvailable bool, req ctrl.Request, client client.Client, clusterSet *mcv1alpha2.ClusterSet) (ClusterID, error)

type ClusterSetID

type ClusterSetID string

Jump to

Keyboard shortcuts

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