conversion

package
v0.0.0-...-21cfbab Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0, Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

TODO move the WorkloadEndpoint converters to is own package. Some refactoring of the annotation and label constants is necessary to avoid circular imports, which is why this has been deferred.

Index

Constants

View Source
const (
	NamespaceLabelPrefix            = "pcns."
	NamespaceProfileNamePrefix      = "kns."
	K8sNetworkPolicyNamePrefix      = "knp.default."
	ServiceAccountLabelPrefix       = "pcsa."
	ServiceAccountProfileNamePrefix = "ksa."

	// AnnotationPodIP is an annotation we apply to pods when assigning them an IP.  It
	// duplicates the value of the Pod.Status.PodIP field, which is set by kubelet but,
	// since we write it ourselves, we can make sure that it is written synchronously
	// and quickly.
	//
	// We set this annotation to the empty string when the WEP is deleted by the CNI plugin.
	// That signals that the IP no longer belongs to this pod.
	AnnotationPodIP = "cni.projectcalico.org/podIP"

	// AnnotationPodIPs is similar for the plural PodIPs field.
	AnnotationPodIPs = "cni.projectcalico.org/podIPs"

	// AnnotationPodIPs is the annotation set by the Amazon VPC CNI plugin.
	AnnotationAWSPodIPs = "vpc.amazonaws.com/pod-ips"

	// AnnotationContainerID stores the container ID of the pod.  This allows us to disambiguate different pods
	// that have the same name and namespace.  For example, stateful set pod that is restarted.  May be missing
	// on older Pods.
	AnnotationContainerID = "cni.projectcalico.org/containerID"

	// NameLabel is a label that can be used to match a serviceaccount or namespace
	// name exactly.
	NameLabel = "projectcalico.org/name"
)
View Source
const (
	SelectorNamespace selectorType = iota
	SelectorPod
)

Variables

This section is empty.

Functions

func IsFinished

func IsFinished(pod *kapiv1.Pod) bool

func SimplifyPorts

func SimplifyPorts(ports []numorstring.Port) []numorstring.Port

SimplifyPorts calculates a minimum set of port ranges that cover the given set of ports. For example, if the input was [80, 81, 82, 9090, "foo"] the output would consist of [80-82, 9090, "foo"] in some order.

Types

type Converter

type Converter interface {
	WorkloadEndpointConverter
	ParseWorkloadEndpointName(workloadName string) (names.WorkloadEndpointIdentifiers, error)
	NamespaceToProfile(ns *kapiv1.Namespace) (*model.KVPair, error)
	IsValidCalicoWorkloadEndpoint(pod *kapiv1.Pod) bool
	IsReadyCalicoPod(pod *kapiv1.Pod) bool
	IsScheduled(pod *kapiv1.Pod) bool
	IsHostNetworked(pod *kapiv1.Pod) bool
	HasIPAddress(pod *kapiv1.Pod) bool
	StagedKubernetesNetworkPolicyToStagedName(stagedK8sName string) string
	K8sNetworkPolicyToCalico(np *networkingv1.NetworkPolicy) (*model.KVPair, error)
	EndpointSliceToKVP(svc *discovery.EndpointSlice) (*model.KVPair, error)
	ServiceToKVP(service *kapiv1.Service) (*model.KVPair, error)
	ProfileNameToNamespace(profileName string) (string, error)
	ServiceAccountToProfile(sa *kapiv1.ServiceAccount) (*model.KVPair, error)
	ProfileNameToServiceAccount(profileName string) (ns, sa string, err error)
	JoinProfileRevisions(nsRev, saRev string) string
	SplitProfileRevision(rev string) (nsRev string, saRev string, err error)
}

func NewConverter

func NewConverter() Converter

type WorkloadEndpointConverter

type WorkloadEndpointConverter interface {
	VethNameForWorkload(namespace, podName string) string
	PodToWorkloadEndpoints(pod *kapiv1.Pod) ([]*model.KVPair, error)
}

func NewWorkloadEndpointConverter

func NewWorkloadEndpointConverter() WorkloadEndpointConverter

Jump to

Keyboard shortcuts

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