util

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToExistingSans added in v1.5.4

func AddToExistingSans(existing []string, new []string) []string

AddToExistingSans merges original sans list with a new sans slice avoiding duplicated values.

func AnnotationsForK0smotronCluster added in v1.4.0

func AnnotationsForK0smotronCluster(kmc *km.Cluster) map[string]string

func DefaultK0smotronClusterLabels added in v1.4.0

func DefaultK0smotronClusterLabels(kmc *km.Cluster) map[string]string

func DownloadCommands added in v1.5.4

func DownloadCommands(preInstalledK0s bool, downloadURL string, version string, k0sInstallPath string) ([]string, error)

DownloadCommands constructs the download commands for a given URL and version.

func EnsureExternalOwner added in v1.7.0

func EnsureExternalOwner(ctx context.Context, name, namespace string, c client.Client) (client.Object, error)

EnsureExternalOwner ensures that an external owner resource with the given name exists in the specified namespace. An external owner resource is used as owner reference for objects that are not in the management cluster. That way we can garbage collect all objects related to a k0smotron cluster deployed in an external cluster by deleting the external owner.

func EnsureFinalizer added in v1.5.4

func EnsureFinalizer(ctx context.Context, c client.Client, o client.Object, finalizer string) (finalizerAdded bool, err error)

EnsureFinalizer adds a finalizer if the object doesn't have a deletionTimestamp set and if the finalizer is not already set. This util is usually used in reconcilers directly after the reconciled object was retrieved and before pause is handled or "defer patch" with the patch helper.

TODO: This function is copied from https://github.com/kubernetes-sigs/cluster-api/blob/v1.9.0/util/finalizers/finalizers.go. Use it once the CAPI dependency is bumped to >=v1.9.0.

func FindNodeAddress added in v0.7.0

func FindNodeAddress(nodes *v1.NodeList) string

FindNodeAddress returns a random node address preferring external address if one is found

func FindStatefulSetPod

func FindStatefulSetPod(ctx context.Context, clientSet *kubernetes.Clientset, statefulSet string, namespace string) (*v1.Pod, error)

FindStatefulSetPod returns a first running pod from a StatefulSet

func GetExternalControllerRef added in v1.7.0

func GetExternalControllerRef(externalOwner metav1.Object) *metav1.OwnerReference

GetExternalControllerRef returns the controller reference for the given external owner object.

func GetExternalOwner added in v1.7.0

func GetExternalOwner(ctx context.Context, name, namespace string, c client.Client) (client.Object, error)

GetExternalOwner retrieves the external owner used in the external cluster for the given name and namespace.

func GetKmcClientFromClusterKubeconfigSecret added in v1.7.0

func GetKmcClientFromClusterKubeconfigSecret(ctx context.Context, managementClusterClient client.Client, kubeconfigRef *kapi.KubeconfigRef) (client.Client, *kubernetes.Clientset, *rest.Config, error)

GetKmcClientFromClusterKubeconfigSecret retrieves a client for the K0smotron cluster using the kubeconfig stored in a secret.

func GetKubeClient added in v1.0.2

func GetKubeClient(ctx context.Context, client client.Client, cluster *clusterv1.Cluster) (*kubernetes.Clientset, error)

func LabelsForEtcdK0smotronCluster added in v1.4.0

func LabelsForEtcdK0smotronCluster(kmc *km.Cluster) map[string]string

func LabelsForK0smotronCluster added in v1.4.0

func LabelsForK0smotronCluster(kmc *km.Cluster) map[string]string

func LabelsForK0smotronControlPlane added in v1.4.0

func LabelsForK0smotronControlPlane(kmc *km.Cluster) map[string]string

func SetExternalOwnerReference added in v1.7.0

func SetExternalOwnerReference(owner metav1.Object, controlled metav1.Object, scheme *runtime.Scheme, externalOwner metav1.Object) error

SetExternalOwnerReference sets the owner reference for the given object trying to use the external owner if provided.

Types

This section is empty.

Jump to

Keyboard shortcuts

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