k8s

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const WatchNamespaceEnvVar = "WATCH_NAMESPACE"

Variables

View Source
var (
	ErrRunningBackup = errors.New("backups are running")
	ErrNoBackups     = errors.New("no backups found")
)
View Source
var ErrLeaseAlreadyHeld = errors.New("lease held by another holder")

Functions

func AcquireLease

func AcquireLease(ctx context.Context, cl client.Client, leaseName, holder, namespace string, checkStale IsHolderStaleFunc) error

AcquireLease attempts to acquire a named lease for the given holder. If isHolderStale is non-nil and the lease is held by a different holder, the callback is invoked to determine whether the current holder is stale. A stale holder is evicted atomically and the lease is granted to the new holder.

func GetLease

func GetLease(ctx context.Context, client client.Client, leaseName, namespace string) (*coordinationv1.Lease, error)

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace of the operator pod

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func GroupExists

func GroupExists(dc *discovery.DiscoveryClient, group string) (bool, error)

GroupExists checks whether a given API group exists in the Kubernetes API Server.

func GroupVersionKindExists

func GroupVersionKindExists(dc *discovery.DiscoveryClient, groupVersion, kind string) (bool, error)

GroupVersionKindExists checks to see whether a given Kind for a given GroupVersion exists in the Kubernetes API Server.

func InitContainer

func InitContainer(cluster *v1beta1.PostgresCluster, componentName, image string,
	pullPolicy corev1.PullPolicy,
	secCtx *corev1.SecurityContext,
	resources corev1.ResourceRequirements,
	component ComponentWithInit,
) corev1.Container

func InitImage

func InitImage(ctx context.Context, cl client.Reader, cluster *v1beta1.PostgresCluster, componentWithInit ComponentWithInit) (string, error)

func ObjectHash

func ObjectHash(obj runtime.Object) (string, error)

func ReleaseLease

func ReleaseLease(ctx context.Context, cl client.Client, leaseName, holder, namespace string) error

ReleaseLease deletes the lease only if it is still held by the given holder. UID and ResourceVersion preconditions prevent accidentally deleting a lease that was re-created by a concurrent acquirer between the Get and Delete.

Types

type ComponentWithInit

type ComponentWithInit interface {
	GetInitContainer() *v1beta1.InitContainerSpec
}

type IsHolderStaleFunc

type IsHolderStaleFunc func(ctx context.Context, currentHolder string) (bool, error)

IsHolderStaleFunc determines whether the current lease holder is stale and can be evicted. Called with the current holder's identity.

Jump to

Keyboard shortcuts

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