Documentation ¶
Index ¶
- Constants
- func VethNameForWorkload(workload string) string
- type Converter
- func (c Converter) HasIPAddress(pod *kapiv1.Pod) bool
- func (c Converter) IsHostNetworked(pod *kapiv1.Pod) bool
- func (c Converter) IsReadyCalicoPod(pod *kapiv1.Pod) bool
- func (c Converter) IsScheduled(pod *kapiv1.Pod) bool
- func (c Converter) K8sNetworkPolicyToCalico(np *extensions.NetworkPolicy) (*model.KVPair, error)
- func (c Converter) NamespaceToProfile(ns *kapiv1.Namespace) (*model.KVPair, error)
- func (c Converter) ParseWorkloadEndpointName(workloadName string) (names.WorkloadEndpointIdentifiers, error)
- func (c Converter) PodToWorkloadEndpoint(pod *kapiv1.Pod) (*model.KVPair, error)
- func (c Converter) ProfileNameToNamespace(profileName string) (string, error)
Constants ¶
const ( NamespaceLabelPrefix = "pcns." NamespaceProfileNamePrefix = "kns." K8sNetworkPolicyNamePrefix = "knp.default." )
const ( SelectorNamespace selectorType = iota SelectorPod )
Variables ¶
This section is empty.
Functions ¶
func VethNameForWorkload ¶
VethNameForWorkload returns a deterministic veth name for the given Kubernetes workload.
Types ¶
type Converter ¶
type Converter struct { }
TODO: make this private and expose a public conversion interface instead
func (Converter) IsReadyCalicoPod ¶
IsReadyCalicoPod returns true if the pod should be shown as a workloadEndpoint in the Calico API and false otherwise.
func (Converter) K8sNetworkPolicyToCalico ¶
func (c Converter) K8sNetworkPolicyToCalico(np *extensions.NetworkPolicy) (*model.KVPair, error)
K8sNetworkPolicyToCalico converts a k8s NetworkPolicy to a model.KVPair.
func (Converter) NamespaceToProfile ¶
NamespaceToProfile converts a Namespace to a Calico Profile. The Profile stores labels from the Namespace which are inherited by the WorkloadEndpoints within the Profile. This Profile also has the default ingress and egress rules, which are both 'allow'.
func (Converter) ParseWorkloadEndpointName ¶
func (c Converter) ParseWorkloadEndpointName(workloadName string) (names.WorkloadEndpointIdentifiers, error)
ParseWorkloadName extracts the Node name, Orchestrator, Pod name and endpoint from the given WorkloadEndpoint name. The expected format for k8s is <node>-k8s-<pod>-<endpoint>
func (Converter) PodToWorkloadEndpoint ¶
PodToWorkloadEndpoint converts a Pod to a WorkloadEndpoint. It assumes the calling code has verified that the provided Pod is valid to convert to a WorkloadEndpoint. PodToWorkloadEndpoint requires a Pods Name and Node Name to be populated. It will fail to convert from a Pod to WorkloadEndpoint otherwise.