networkattachment

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 10 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNetworksAnnotation

func CreateNetworksAnnotation(namespace string, nads []string) (map[string]string, error)

CreateNetworksAnnotation returns pod annotation for network-attachment-definition list e.g. k8s.v1.cni.cncf.io/networks: '[{"name": "internalapi", "namespace": "openstack"},{"name": "storage", "namespace": "openstack"}]' NOTE: Deprecated, use EnsureNetworksAnnotation

func EnsureNetworksAnnotation added in v0.6.0

func EnsureNetworksAnnotation(
	nadList []networkv1.NetworkAttachmentDefinition,
) (map[string]string, error)

EnsureNetworksAnnotation returns pod annotation for network-attachment-definition list e.g. k8s.v1.cni.cncf.io/networks: '[{"name": "internalapi", "namespace": "openstack"},{"name": "storage", "namespace": "openstack"}]' If `ipam.gateway` is defined in the NAD, the annotation will contain the `default-route` for that network: e.g. k8s.v1.cni.cncf.io/networks: '[{"name":"internalapi","namespace":"openstack","interface":"internalapi","default-route":["10.1.2.200"]}]'

func GetJSONPathFromConfig added in v0.6.0

func GetJSONPathFromConfig(netAtt networkv1.NetworkAttachmentDefinition, path string) (string, error)

GetJSONPathFromConfig - returns the result of the jsonPath as string from the NetworkAttachmentDefinition config. if the NAD has no config, an empty string is returned. The jsonPath must be in the format e.g. ".ipam"

func GetNADWithName

func GetNADWithName(
	ctx context.Context,
	h *helper.Helper,
	name string,
	namespace string,
) (*networkv1.NetworkAttachmentDefinition, error)

GetNADWithName - Get network-attachment-definition with name in namespace

func GetNetworkIFName

func GetNetworkIFName(nad string) string

GetNetworkIFName returns the interface name base on the NAD name the interface name in Linux must not be longer then 15 chars.

func GetNetworkStatusFromAnnotation

func GetNetworkStatusFromAnnotation(annotations map[string]string) ([]networkv1.NetworkStatus, error)

GetNetworkStatusFromAnnotation returns NetworkStatus list with networking details the pods are attached to

func VerifyNetworkStatusFromAnnotation

func VerifyNetworkStatusFromAnnotation(
	ctx context.Context,
	helper *helper.Helper,
	networkAttachments []string,
	serviceLabels map[string]string,
	readyCount int32,
) (bool, map[string][]string, error)

VerifyNetworkStatusFromAnnotation - verifies if NetworkStatus annotation for the pods of a deployment, pods identified via the service label selector, matches the passed in network attachments and the number of per network IPs the ready count of the deployment. Return true if count matches with the list of IPs per network.

Types

This section is empty.

Jump to

Keyboard shortcuts

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