clusterutils

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package clusterutils provides functions to handle cluster actions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTopologySpreadConstraint added in v1.27.4

func AddTopologySpreadConstraint(cluster *apiv1.Cluster)

AddTopologySpreadConstraint appends a soft topology spread constraint that distributes all CNPG-managed pods (instances and jobs) across nodes. Call this on E2E clusters to prevent co-location of concurrent test workloads.

func AllPodsHaveAnnotations

func AllPodsHaveAnnotations(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
	annotations map[string]string,
) (bool, error)

AllPodsHaveAnnotations verifies if the annotations defined in a map are included in all the pods of a cluster

func AllPodsHaveLabels

func AllPodsHaveLabels(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
	labels map[string]string,
) (bool, error)

AllPodsHaveLabels verifies if the labels defined in a map are included in all the pods of a cluster

func Get

func Get(
	ctx context.Context,
	crudClient client.Client,
	namespace, name string,
) (*apiv1.Cluster, error)

Get gets a cluster given name and namespace

func GetFirstReplica added in v1.27.3

func GetFirstReplica(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
) (*corev1.Pod, error)

GetFirstReplica gets the first replica pod from a cluster

func GetPrimary

func GetPrimary(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
) (*corev1.Pod, error)

GetPrimary gets the primary pod of a cluster

func GetReplicas

func GetReplicas(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
) (*corev1.PodList, error)

GetReplicas gets a slice containing all the replica pods of a cluster

func HasAnnotations

func HasAnnotations(
	cluster *apiv1.Cluster,
	annotations map[string]string,
) bool

HasAnnotations verifies that the annotations of a cluster contain a specified annotations map

func HasLabels

func HasLabels(
	cluster *apiv1.Cluster,
	labels map[string]string,
) bool

HasLabels verifies that the labels of a cluster contain a specified labels map

func ListPods

func ListPods(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
) (*corev1.PodList, error)

ListPods gathers the current list of instance pods for a cluster in a namespace

func ScaleSize

func ScaleSize(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
	newClusterSize int,
) error

ScaleSize scales a cluster to the requested size

Types

This section is empty.

Jump to

Keyboard shortcuts

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