getters

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package getters contains utility functions to get k8s resources and at the same time to extract data from the same resources.

Package getters provides functions to get k8s resources and liqo custom resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigMapByLabel

func GetConfigMapByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*corev1.ConfigMap, error)

GetConfigMapByLabel it returns a configmap instance that matches the given label selector.

func GetIPAMStorageByLabel

func GetIPAMStorageByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector) (*netv1alpha1.IpamStorage, error)

GetIPAMStorageByLabel it returns a IPAMStorage instance that matches the given label selector.

func GetNamespaceMapByLabel added in v0.9.0

func GetNamespaceMapByLabel(ctx context.Context, cl client.Client,
	ns string, lSelector labels.Selector) (*virtualkubeletv1alpha1.NamespaceMap, error)

GetNamespaceMapByLabel returns the NamespaceMapping with the given labels.

func GetNetworkConfigByLabel

func GetNetworkConfigByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*netv1alpha1.NetworkConfig, error)

GetNetworkConfigByLabel it returns a networkconfigs instance that matches the given label selector.

func GetNodeFromVirtualNode added in v0.9.0

func GetNodeFromVirtualNode(ctx context.Context, cl client.Client, virtualNode *virtualkubeletv1alpha1.VirtualNode) (*corev1.Node, error)

GetNodeFromVirtualNode returns the node object from the given virtual node name.

func GetOffloadingByNamespace added in v0.5.0

func GetOffloadingByNamespace(ctx context.Context, cl client.Client, namespace string) (*offloadingv1alpha1.NamespaceOffloading, error)

GetOffloadingByNamespace returns the NamespaceOffloading resource for the given namespace.

func GetPodByLabel

func GetPodByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector, fSelector fields.Selector) (*corev1.Pod, error)

GetPodByLabel it returns a pod instance that matches the given label and field selector.

func GetResourceOfferByLabel added in v0.5.0

func GetResourceOfferByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*sharingv1alpha1.ResourceOffer, error)

GetResourceOfferByLabel returns the ResourceOffer with the given labels.

func GetSecretByLabel

func GetSecretByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*corev1.Secret, error)

GetSecretByLabel it returns a secret instance that matches the given label selector.

func GetServiceByLabel

func GetServiceByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*corev1.Service, error)

GetServiceByLabel it returns a service instance that matches the given label selector.

func GetTunnelEndpoint added in v0.6.0

func GetTunnelEndpoint(ctx context.Context, cl client.Client,
	destinationClusterIdentity *discoveryv1alpha1.ClusterIdentity, namespace string) (*netv1alpha1.TunnelEndpoint, error)

GetTunnelEndpoint retrieves the tunnelEndpoint resource related to a cluster.

func ListNetworkConfigsByLabel added in v0.7.0

func ListNetworkConfigsByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*netv1alpha1.NetworkConfigList, error)

ListNetworkConfigsByLabel it returns a NetworkConfig list that matches the given label selector.

func ListNodesByClusterID added in v0.9.0

func ListNodesByClusterID(ctx context.Context, cl client.Client, clusterID *discoveryv1alpha1.ClusterIdentity) (*corev1.NodeList, error)

ListNodesByClusterID returns the node list that matches the given cluster id.

func ListOffloadedPods added in v0.6.0

func ListOffloadedPods(ctx context.Context, cl client.Client, namespace string) (corev1.PodList, error)

ListOffloadedPods returns the list of pods offloaded from the given namespace.

func ListResourceOfferByLabel added in v0.9.0

func ListResourceOfferByLabel(ctx context.Context, cl client.Client,
	ns string, lSelector labels.Selector) (*sharingv1alpha1.ResourceOfferList, error)

ListResourceOfferByLabel returns the ResourceOfferList with the given labels.

func ListVirtualNodesByLabels added in v0.9.0

func ListVirtualNodesByLabels(ctx context.Context, cl client.Client, lSelector labels.Selector) (*virtualkubeletv1alpha1.VirtualNodeList, error)

ListVirtualNodesByLabels returns the list of virtual nodes.

func MapForeignClustersByLabel added in v0.7.0

func MapForeignClustersByLabel(ctx context.Context, cl client.Client,
	lSelector labels.Selector) (map[string]discoveryv1alpha1.ForeignCluster, error)

MapForeignClustersByLabel returns a map of foreign clusters indexed their names.

func RetrieveClusterIDFromConfigMap

func RetrieveClusterIDFromConfigMap(cm *corev1.ConfigMap) (*discoveryv1alpha1.ClusterIdentity, error)

RetrieveClusterIDFromConfigMap retrieves ClusterIdentity from a given configmap.

func RetrieveClusterIDsFromVirtualNodes added in v0.9.0

func RetrieveClusterIDsFromVirtualNodes(virtualNodes *virtualkubeletv1alpha1.VirtualNodeList) []string

RetrieveClusterIDsFromVirtualNodes returns the remote cluster IDs in a list of VirtualNodes avoiding duplicates.

func RetrieveEndpointFromService

func RetrieveEndpointFromService(svc *corev1.Service, svcType corev1.ServiceType, portName string) (endpointIP, endpointPort string, err error)

RetrieveEndpointFromService retrieves an ip address and port from a given service object based on the service and port name.

func RetrieveRemoteClusterIDFromNode added in v0.9.0

func RetrieveRemoteClusterIDFromNode(node *corev1.Node) (string, error)

RetrieveRemoteClusterIDFromNode retrieves the remote cluster ID from a given node object. If the node has no RemoteCLusterID label, it returns a void string without error.

func RetrieveWGEPFromLoadBalancer

func RetrieveWGEPFromLoadBalancer(svc *corev1.Service, portName string) (endpointIP, endpointPort string, err error)

RetrieveWGEPFromLoadBalancer retrieves the WireGuard endpoint from a LoadBalancer service.

func RetrieveWGEPFromNodePort

func RetrieveWGEPFromNodePort(svc *corev1.Service, annotationKey, portName string) (endpointIP, endpointPort string, err error)

RetrieveWGEPFromNodePort retrieves the WireGuard endpoint from a NodePort service.

func RetrieveWGEPFromService

func RetrieveWGEPFromService(svc *corev1.Service, annotationKey, portName string) (endpointIP, endpointPort string, err error)

RetrieveWGEPFromService retrieves the WireGuard endpoint from a generic service.

func RetrieveWGPubKeyFromSecret

func RetrieveWGPubKeyFromSecret(secret *corev1.Secret, keyName string) (pubKey wgtypes.Key, err error)

RetrieveWGPubKeyFromSecret retrieves the WireGuard public key from a given secret if present.

Types

type NetworkConfig

type NetworkConfig struct {
	PodCIDR         string
	ExternalCIDR    string
	ServiceCIDR     string
	ReservedSubnets []string
}

NetworkConfig holds the liqo network configuration.

func RetrieveNetworkConfiguration

func RetrieveNetworkConfiguration(ipamS *netv1alpha1.IpamStorage) (*NetworkConfig, error)

RetrieveNetworkConfiguration returns the podCIDR, serviceCIDR, reservedSubnets and the externalCIDR as saved in the ipams.net.liqo.io custom resource instance.

Jump to

Keyboard shortcuts

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