getters

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 28 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 GetConfigurationByClusterID added in v1.0.0

func GetConfigurationByClusterID(ctx context.Context, cl client.Client,
	clusterID liqov1beta1.ClusterID, namespace string) (*networkingv1beta1.Configuration, error)

GetConfigurationByClusterID returns the Configuration resource with the given clusterID. If tenantNamespace is empty this function searches in all the namespaces in the cluster.

func GetConnectionByClusterID added in v1.0.0

func GetConnectionByClusterID(ctx context.Context, cl client.Client, clusterID string) (*networkingv1beta1.Connection, error)

GetConnectionByClusterID returns the Connection resource with the given clusterID.

func GetConnectionByClusterIDInNamespace added in v1.0.0

func GetConnectionByClusterIDInNamespace(ctx context.Context, cl client.Client, clusterID, namespace string) (*networkingv1beta1.Connection, error)

GetConnectionByClusterIDInNamespace returns the Connection resource with the given clusterID in the given namespace.

func GetContainerImageVersion added in v1.0.0

func GetContainerImageVersion(containers []corev1.Container, containerName string) (version string, err error)

GetContainerImageVersion gets the version of the image of the container with the given name from a list of containers.

func GetControlPlaneIdentityByClusterID added in v1.0.0

func GetControlPlaneIdentityByClusterID(ctx context.Context, cl client.Client,
	clusterID liqov1beta1.ClusterID) (*authv1beta1.Identity, error)

GetControlPlaneIdentityByClusterID returns the Identity of type ControlPlane for the given cluster id.

func GetControlPlaneKubeconfigSecretByClusterID added in v1.0.0

func GetControlPlaneKubeconfigSecretByClusterID(ctx context.Context, cl client.Client,
	clusterID liqov1beta1.ClusterID) (*corev1.Secret, error)

GetControlPlaneKubeconfigSecretByClusterID returns the Secret containing the Kubeconfig of a ControlPlane Identity given the cluster id.

func GetControllerManagerDeployment added in v1.0.0

func GetControllerManagerDeployment(ctx context.Context, cl client.Client, liqoNamespace string) (*appsv1.Deployment, error)

GetControllerManagerDeployment returns the liqo controller manager deployment.

func GetControllerManagerDeploymentWithDynamicClient added in v1.0.0

func GetControllerManagerDeploymentWithDynamicClient(ctx context.Context,
	dynClient dynamic.Interface, liqoNamespace string) (*appsv1.Deployment, error)

GetControllerManagerDeploymentWithDynamicClient retrieves the controller manager deployment usingg the dynamic client.

func GetGatewayClientByClusterID added in v1.0.0

func GetGatewayClientByClusterID(ctx context.Context, cl client.Client,
	remoteClusterID liqov1beta1.ClusterID, namespace string) (*networkingv1beta1.GatewayClient, error)

GetGatewayClientByClusterID returns the GatewayClient resource with the given clusterID. If tenantNamespace is empty this function searches in all the namespaces in the cluster.

func GetGatewayServerByClusterID added in v1.0.0

func GetGatewayServerByClusterID(ctx context.Context, cl client.Client,
	remoteClusterID liqov1beta1.ClusterID, namespace string) (*networkingv1beta1.GatewayServer, error)

GetGatewayServerByClusterID returns the GatewayServer resource with the given clusterID. If tenantNamespace is empty this function searches in all the namespaces in the cluster.

func GetGatewaysByClusterID added in v1.0.0

GetGatewaysByClusterID returns both the GatewayServer and GatewayClient resource with the given clusterID, if not found it returns a nil pointer. Normally, with a common peering, this function should return only one gateway either the client or the server.

func GetIdentityFromResourceSlice added in v1.0.0

func GetIdentityFromResourceSlice(ctx context.Context, cl client.Client,
	clusterID liqov1beta1.ClusterID, resourceSliceName string) (*authv1beta1.Identity, error)

GetIdentityFromResourceSlice returns the Identity of type ResourceSlice for the given cluster id and resourceslice name.

func GetKubeconfigSecretFromIdentity added in v1.0.0

func GetKubeconfigSecretFromIdentity(ctx context.Context, cl client.Client, identity *authv1beta1.Identity) (*corev1.Secret, error)

GetKubeconfigSecretFromIdentity returns the Secret referenced in the status of the given Identity.

func GetLiqoVersion added in v0.10.2

func GetLiqoVersion(ctx context.Context, cl client.Client, liqoNamespace string) (string, error)

GetLiqoVersion returns the installed Liqo version.

func GetNamespaceMapByLabel added in v0.9.0

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

GetNamespaceMapByLabel returns the NamespaceMapping with the given labels.

func GetNetworksByLabel added in v1.0.0

func GetNetworksByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector, namespace string) ([]ipamv1alpha1.Network, error)

GetNetworksByLabel retrieves the Network resources with the given labelSelector.

func GetNodeFromVirtualNode added in v0.9.0

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

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

func GetNonceSecretByClusterID added in v1.0.0

func GetNonceSecretByClusterID(ctx context.Context, cl client.Client, remoteClusterID liqov1beta1.ClusterID,
	tenantNamespace string) (*corev1.Secret, error)

GetNonceSecretByClusterID returns the secret containing the nonce to be signed by the consumer cluster. If tenantNamespace is empty this function searches in all the namespaces in the cluster.

func GetOffloadingByNamespace added in v0.5.0

func GetOffloadingByNamespace(ctx context.Context, cl client.Client, namespace string) (*offloadingv1beta1.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 GetPublicKeyByClusterID added in v1.0.0

func GetPublicKeyByClusterID(ctx context.Context, cl client.Client,
	remoteClusterID liqov1beta1.ClusterID, namespace string) (*networkingv1beta1.PublicKey, error)

GetPublicKeyByClusterID returns the PublicKey resource with the given clusterID.

func GetQuotaByUser added in v1.0.0

func GetQuotaByUser(ctx context.Context, cl client.Client,
	user string) (*offloadingv1beta1.Quota, error)

GetQuotaByUser returns the list of Quotas for the given user.

func GetResourceSliceIdentitiesByClusterID added in v1.0.0

func GetResourceSliceIdentitiesByClusterID(ctx context.Context, cl client.Client,
	clusterID liqov1beta1.ClusterID) ([]authv1beta1.Identity, error)

GetResourceSliceIdentitiesByClusterID returns the list of Identities of type ResourceSlice for the given cluster id.

func GetResourceSliceKubeconfigSecretsByClusterID added in v1.0.0

func GetResourceSliceKubeconfigSecretsByClusterID(ctx context.Context, cl client.Client, clusterID string) ([]corev1.Secret, error)

GetResourceSliceKubeconfigSecretsByClusterID returns the list of Secrets containing the Kubeconfig of a ResourceSlice Identity given the cluster id.

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 GetSignedNonceSecretByClusterID added in v1.0.0

func GetSignedNonceSecretByClusterID(
	ctx context.Context, cl client.Client, remoteClusterID liqov1beta1.ClusterID, tenantNamespace string) (*corev1.Secret, error)

GetSignedNonceSecretByClusterID returns the secret containing the nonce signed by the consumer cluster. If tenantNamespace is empty this function searches in all the namespaces in the cluster.

func GetTenantByClusterID added in v1.0.0

func GetTenantByClusterID(
	ctx context.Context, cl client.Client, clusterID liqov1beta1.ClusterID, tenantNamespace string) (*authv1beta1.Tenant, error)

GetTenantByClusterID returns the Tenant resource for the given cluster id.

func GetTenantByName added in v1.0.0

func GetTenantByName(
	ctx context.Context, cl client.Client, name string, tenantNamespace string) (*authv1beta1.Tenant, error)

GetTenantByName returns the Tenant resource given its name.

func GetUniqueNetworkByLabel added in v1.0.0

func GetUniqueNetworkByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector, namespace string) (*ipamv1alpha1.Network, error)

GetUniqueNetworkByLabel retrieves the Network resource with the given label selector. It returns error if multiple resources are found.

func ListClusterRoleBindingsByLabel added in v1.0.0

func ListClusterRoleBindingsByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector) ([]rbacv1.ClusterRoleBinding, error)

ListClusterRoleBindingsByLabel returns the ClusterRoleBindings that match the given label selector.

func ListClusterRolesByLabel added in v1.0.0

func ListClusterRolesByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector) ([]rbacv1.ClusterRole, error)

ListClusterRolesByLabel returns the ClusterRoles that match the given label selector.

func ListConfigurationsByLabel added in v1.0.0

func ListConfigurationsByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector) (*networkingv1beta1.ConfigurationList, error)

ListConfigurationsByLabel returns the Configuration resource with the given labels.

func ListConfigurationsInNamespaceByLabel added in v1.0.0

func ListConfigurationsInNamespaceByLabel(ctx context.Context, cl client.Client,
	ns string, lSelector labels.Selector) (*networkingv1beta1.ConfigurationList, error)

ListConfigurationsInNamespaceByLabel returns the Configuration resources with the given labels.

func ListConnectionsByLabel added in v1.0.0

func ListConnectionsByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*networkingv1beta1.ConnectionList, error)

ListConnectionsByLabel returns the Connection resource with the given labels.

func ListFirewallConfigurationsByLabel added in v1.0.0

func ListFirewallConfigurationsByLabel(ctx context.Context, cl client.Client,
	lSelector labels.Selector) (*networkingv1beta1.FirewallConfigurationList, error)

ListFirewallConfigurationsByLabel returns the FirewallConfiguration resource with the given labels.

func ListFirewallConfigurationsInNamespaceByLabel added in v1.0.0

func ListFirewallConfigurationsInNamespaceByLabel(ctx context.Context, cl client.Client,
	ns string, lSelector labels.Selector) (*networkingv1beta1.FirewallConfigurationList, error)

ListFirewallConfigurationsInNamespaceByLabel returns the FirewallConfiguration resource with the given labels.

func ListGeneveTunnelsByLabels added in v1.0.0

func ListGeneveTunnelsByLabels(ctx context.Context, cl client.Client,
	lSelector labels.Selector) (*networkingv1beta1.GeneveTunnelList, error)

ListGeneveTunnelsByLabels returns the list of genevetunnels resources.

func ListIPsByLabel added in v1.0.0

func ListIPsByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector) (*ipamv1alpha1.IPList, error)

ListIPsByLabel returns the IP resource with the given labels.

func ListInternalFabricsByLabels added in v1.0.0

func ListInternalFabricsByLabels(ctx context.Context, cl client.Client,
	lSelector labels.Selector) (*networkingv1beta1.InternalFabricList, error)

ListInternalFabricsByLabels returns the list of internalfabrics resources.

func ListInternalNodesByLabels added in v1.0.0

func ListInternalNodesByLabels(ctx context.Context, cl client.Client,
	lSelector labels.Selector) (*networkingv1beta1.InternalNodeList, error)

ListInternalNodesByLabels returns the list of internalnodes resources. (i.e. nodes created by Liqo).

func ListLiqoNodes added in v1.0.0

func ListLiqoNodes(ctx context.Context, cl client.Client) (*corev1.NodeList, error)

ListLiqoNodes returns the list of nodes of type virtual-node.

func ListNamespaceMapsByLabel added in v1.0.0

func ListNamespaceMapsByLabel(ctx context.Context, cl client.Client,
	ns string, lSelector labels.Selector) ([]offloadingv1beta1.NamespaceMap, error)

ListNamespaceMapsByLabel returns the NamespaceMaps that match the given label selector.

func ListNetworksByLabel added in v1.0.0

func ListNetworksByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*ipamv1alpha1.NetworkList, error)

ListNetworksByLabel returns the Network resource with the given labels.

func ListNodesByClusterID added in v0.9.0

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

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

func ListNotLiqoNodes added in v1.0.0

func ListNotLiqoNodes(ctx context.Context, cl client.Client) (*corev1.NodeList, error)

ListNotLiqoNodes returns the list of nodes not created by Liqo.

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 ListPhysicalNodes added in v1.0.0

func ListPhysicalNodes(ctx context.Context, cl client.Client) (*corev1.NodeList, error)

ListPhysicalNodes returns the list of physical nodes. (i.e. nodes not created by Liqo).

func ListPublicKeysByLabel added in v1.0.0

func ListPublicKeysByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) (*networkingv1beta1.PublicKeyList, error)

ListPublicKeysByLabel returns the PublicKey resource with the given labels.

func ListResourceSlicesByClusterID added in v1.0.0

func ListResourceSlicesByClusterID(ctx context.Context, cl client.Client,
	remoteClusterID liqov1beta1.ClusterID) ([]authv1beta1.ResourceSlice, error)

ListResourceSlicesByClusterID returns the list of ResourceSlices for the given cluster id.

func ListResourceSlicesByLabel added in v1.0.0

func ListResourceSlicesByLabel(ctx context.Context, cl client.Client,
	ns string, lSelector labels.Selector) ([]authv1beta1.ResourceSlice, error)

ListResourceSlicesByLabel returns the ResourceSlice list that matches the given label selector.

func ListRoleBindingsByLabel added in v1.0.0

func ListRoleBindingsByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) ([]rbacv1.RoleBinding, error)

ListRoleBindingsByLabel returns the RoleBindings that match the given label selector.

func ListRolesByLabel added in v1.0.0

func ListRolesByLabel(ctx context.Context, cl client.Client, ns string, lSelector labels.Selector) ([]rbacv1.Role, error)

ListRolesByLabel returns the Roles that match the given label selector.

func ListRouteConfigurationsByLabel added in v1.0.0

func ListRouteConfigurationsByLabel(ctx context.Context, cl client.Client,
	lSelector labels.Selector) (*networkingv1beta1.RouteConfigurationList, error)

ListRouteConfigurationsByLabel returns the RouteConfiguration resource with the given labels.

func ListRouteConfigurationsInNamespaceByLabel added in v1.0.0

func ListRouteConfigurationsInNamespaceByLabel(ctx context.Context, cl client.Client,
	ns string, lSelector labels.Selector) (*networkingv1beta1.RouteConfigurationList, error)

ListRouteConfigurationsInNamespaceByLabel returns the RouteConfiguration resource in a namespace with the given labels.

func ListShadowPodsByCreator added in v1.0.0

func ListShadowPodsByCreator(ctx context.Context, cl client.Client, creator string) (*offloadingv1beta1.ShadowPodList, error)

ListShadowPodsByCreator returns the list of ShadowPods created by the given user.

func ListVirtualKubeletPodsFromVirtualNode added in v0.9.4

func ListVirtualKubeletPodsFromVirtualNode(ctx context.Context, cl client.Client,
	vn *offloadingv1beta1.VirtualNode) (*corev1.PodList, error)

ListVirtualKubeletPodsFromVirtualNode returns the list of pods running a VirtualNode's VirtualKubelet.

func ListVirtualNodesByClusterID added in v1.0.0

func ListVirtualNodesByClusterID(ctx context.Context, cl client.Client,
	remoteClusterID liqov1beta1.ClusterID) ([]offloadingv1beta1.VirtualNode, error)

ListVirtualNodesByClusterID returns the list of virtual nodes for the given cluster id.

func ListVirtualNodesByLabels added in v0.9.0

func ListVirtualNodesByLabels(ctx context.Context, cl client.Client, lSelector labels.Selector) (*offloadingv1beta1.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]liqov1beta1.ForeignCluster, error)

MapForeignClustersByLabel returns a map of foreign clusters indexed their names.

func RetrieveClusterIDFromConfigMap

func RetrieveClusterIDFromConfigMap(cm *corev1.ConfigMap) (liqov1beta1.ClusterID, error)

RetrieveClusterIDFromConfigMap retrieves ClusterID from a given configmap.

func RetrieveClusterIDTelemetryFromConfigMap added in v1.0.1

func RetrieveClusterIDTelemetryFromConfigMap(cm *corev1.ConfigMap) (string, error)

RetrieveClusterIDTelemetryFromConfigMap retrieves telemetry ClusterID from a given configmap.

func RetrieveClusterIDsFromObjectsLabels added in v1.0.0

func RetrieveClusterIDsFromObjectsLabels[T metav1.Object](objectList []T) []string

RetrieveClusterIDsFromObjectsLabels returns the remote cluster IDs in a list of objects avoiding duplicates.

func RetrieveClusterIDsFromVirtualNodes added in v0.9.0

func RetrieveClusterIDsFromVirtualNodes(virtualNodes *offloadingv1beta1.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 RetrieveRemoteClusterIDFromMeta added in v1.0.2

func RetrieveRemoteClusterIDFromMeta(meta *metav1.ObjectMeta) (liqov1beta1.ClusterID, error)

RetrieveRemoteClusterIDFromMeta retrieves the remote cluster ID from the labels of a generic kubernetes object.

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.

Types

type NetworkConfig

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

NetworkConfig holds the liqo network configuration.

Jump to

Keyboard shortcuts

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