getters

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 27 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

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

GetConfigurationByClusterID returns the Configuration resource with the given clusterID.

func GetConnectionByClusterID

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

GetConnectionByClusterID returns the Connection resource with the given clusterID.

func GetConnectionByClusterIDInNamespace

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

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

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

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

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

GetControllerManagerDeployment returns the liqo controller manager deployment.

func GetControllerManagerDeploymentWithDynamicClient

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

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

GetGatewayClientByClusterID returns the GatewayClient resource with the given clusterID.

func GetGatewayServerByClusterID

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

GetGatewayServerByClusterID returns the GatewayServer resource with the given clusterID.

func GetGatewaysByClusterID

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

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

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

func GetNetworksByLabel(ctx context.Context, cl client.Client, lSelector labels.Selector) ([]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

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

GetNonceSecretByClusterID returns the secret containing the nonce to be signed by the consumer 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

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

GetPublicKeyByClusterID returns the PublicKey resource with the given clusterID.

func GetQuotaByUser

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

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

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

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

GetSignedNonceSecretByClusterID returns the secret containing the nonce signed by the consumer cluster.

func GetTenantByClusterID

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

GetTenantByClusterID returns the Tenant resource for the given cluster id.

func GetUniqueNetworkByLabel

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

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

func ListClusterRoleBindingsByLabel

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

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

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

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

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

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

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

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

ListGeneveTunnelsByLabels returns the list of genevetunnels resources.

func ListIPsByLabel

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

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

ListInternalFabricsByLabels returns the list of internalfabrics resources.

func ListInternalNodesByLabels

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

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

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

func ListNamespaceMapsByLabel

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

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

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

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

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

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

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

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

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

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

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

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

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 RetrieveClusterIDsFromObjectsLabels

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 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