common

package
v1.11.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: Apache-2.0 Imports: 17 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
)

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,
	}

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

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 FilterEndpointSubsets

func FilterEndpointSubsets(subsets []corev1.EndpointSubset) []corev1.EndpointSubset

FilterEndpointSubsets keeps IPs only and removes other fields from EndpointSubset which are unnecessary information for other member clusters.

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

func ValidateLocalClusterClaim added in v1.11.0

func ValidateLocalClusterClaim(c client.Client, clusterSet *multiclusterv1alpha1.ClusterSet) (clusterID ClusterID, clusterSetID ClusterSetID, err error)

Types

type ClusterID

type ClusterID string

type ClusterSetID

type ClusterSetID string

Jump to

Keyboard shortcuts

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