utils

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 34 Imported by: 1

Documentation

Overview

Package utils contains otherwise uncategorized kubernetes relative functions

Index

Constants

View Source
const (
	// ClusterLabelName is the name of the label cluster which the backup CR belongs to
	ClusterLabelName = MetadataNamespace + "/cluster"

	// JobRoleLabelName is the name of the label containing the purpose of the executed job
	// the value could be import, initdb, join
	JobRoleLabelName = MetadataNamespace + "/jobRole"

	// PvcRoleLabelName is the name of the label containing the purpose of the pvc
	PvcRoleLabelName = MetadataNamespace + "/pvcRole"

	// TablespaceNameLabelName is the name of the label containing tablespace name that a pvc holds
	TablespaceNameLabelName = "cnpg.io/tablespaceName"

	// PodRoleLabelName is the name of the label containing the podRole value
	PodRoleLabelName = MetadataNamespace + "/podRole"

	// InstanceNameLabelName is the name of the label containing the instance name
	InstanceNameLabelName = MetadataNamespace + "/instanceName"

	// BackupNameLabelName is the name of the label containing the backup id, available on backup resources
	BackupNameLabelName = MetadataNamespace + "/backupName"

	// PgbouncerNameLabel is the name of the label of containing the pooler name
	PgbouncerNameLabel = MetadataNamespace + "/poolerName"

	// ClusterRoleLabelName is the name of label applied to instances to mark primary/replica
	// Deprecated: Use ClusterInstanceRoleLabelName.
	ClusterRoleLabelName = "role"

	// ClusterInstanceRoleLabelName is the name of label applied to instances to mark primary/replica
	ClusterInstanceRoleLabelName = MetadataNamespace + "/instanceRole"

	// ImmediateBackupLabelName is the name of the label applied to backups to tell if the first scheduled backup is
	// taken immediately or not
	ImmediateBackupLabelName = MetadataNamespace + "/immediateBackup"

	// ParentScheduledBackupLabelName is the name of the label applied to backups to easily tell the name of parent
	// scheduled backup if a backup is created by a scheduled backup
	ParentScheduledBackupLabelName = MetadataNamespace + "/scheduled-backup"

	// WatchedLabelName the name of the label which tell if a resource change will be automatically reloaded by instance
	// or not, use for Secrets or ConfigMaps
	WatchedLabelName = MetadataNamespace + "/reload"

	// BackupTimelineLabelName is the name or the label where the timeline of a backup is kept
	BackupTimelineLabelName = MetadataNamespace + "/backupTimeline"

	// BackupYearLabelName is the name of the label where the year of a backup is kept
	BackupYearLabelName = MetadataNamespace + "/backupYear"

	// BackupMonthLabelName is the name of the label where the month of a backup is kept
	BackupMonthLabelName = MetadataNamespace + "/backupMonth"

	// BackupDateLabelName is the name of the label where the date of a backup in 'YYYYMMDD' format is kept
	BackupDateLabelName = MetadataNamespace + "/backupDate"

	// IsOnlineBackupLabelName is the name of the label used to specify whether a backup was online
	IsOnlineBackupLabelName = MetadataNamespace + "/onlineBackup"
)

When you add a new label or annotation, please make sure that you also update the publicly visible documentation, namely the `docs/src/labels_annotations.md` file

View Source
const (
	// OperatorVersionAnnotationName is the name of the annotation containing
	// the version of the operator that generated a certain object
	OperatorVersionAnnotationName = MetadataNamespace + "/operatorVersion"

	// AppArmorAnnotationPrefix will be the name of the AppArmor profile to apply
	// This is required for Azure but can be set in other environments
	AppArmorAnnotationPrefix = "container.apparmor.security.beta.kubernetes.io"

	// ReconciliationLoopAnnotationName is the name of the annotation controlling
	// the status of the reconciliation loop for the cluster
	ReconciliationLoopAnnotationName = MetadataNamespace + "/reconciliationLoop"

	// HibernateClusterManifestAnnotationName contains the hibernated cluster manifest
	// Deprecated. Replaced by: ClusterManifestAnnotationName. This annotation is
	// kept for backward compatibility
	HibernateClusterManifestAnnotationName = MetadataNamespace + "/hibernateClusterManifest"

	// HibernatePgControlDataAnnotationName contains the pg_controldata output of the hibernated cluster
	// Deprecated. Replaced by: PgControldataAnnotationName. This annotation is
	// kept for backward compatibility
	HibernatePgControlDataAnnotationName = MetadataNamespace + "/hibernatePgControlData"

	// PodEnvHashAnnotationName is the name of the annotation containing the podEnvHash value
	// Deprecated: the PodSpec annotation covers the environment drift. This annotation is
	// kept for backward compatibility
	PodEnvHashAnnotationName = MetadataNamespace + "/podEnvHash"

	// PodSpecAnnotationName is the name of the annotation with the PodSpec derived from the cluster
	PodSpecAnnotationName = MetadataNamespace + "/podSpec"

	// ClusterManifestAnnotationName is the name of the annotation containing the cluster manifest
	ClusterManifestAnnotationName = MetadataNamespace + "/clusterManifest"

	// CoredumpFilter stores the value defined by the user to set in /proc/self/coredump_filter
	CoredumpFilter = MetadataNamespace + "/coredumpFilter"

	// PgControldataAnnotationName is the name of the annotation containing the pg_controldata output of the cluster
	PgControldataAnnotationName = MetadataNamespace + "/pgControldata"

	// SkipWalArchiving is the name of the annotation which turns off WAL archiving
	SkipWalArchiving = MetadataNamespace + "/skipWalArchiving"

	// ClusterSerialAnnotationName is the name of the annotation containing the
	// serial number of the node
	ClusterSerialAnnotationName = MetadataNamespace + "/nodeSerial"

	// ClusterReloadAnnotationName is the name of the annotation containing the
	// latest reload time trigger by external
	ClusterReloadAnnotationName = MetadataNamespace + "/reloadedAt"

	// PVCStatusAnnotationName is the name of the annotation that shows the current status of the PVC.
	// The status can be "initializing", "ready" or "detached"
	PVCStatusAnnotationName = MetadataNamespace + "/pvcStatus"

	// LegacyBackupAnnotationName is the name of the annotation represents whether taking a backup without passing
	// the name argument even on barman version 3.3.0+. The value can be "true" or "false"
	LegacyBackupAnnotationName = MetadataNamespace + "/forceLegacyBackup"

	// HibernationAnnotationName is the name of the annotation which used to declaratively hibernate a
	// PostgreSQL cluster
	HibernationAnnotationName = MetadataNamespace + "/hibernation"

	// PoolerSpecHashAnnotationName is the name of the annotation added to the deployment to tell
	// the hash of the Pooler Specification
	PoolerSpecHashAnnotationName = MetadataNamespace + "/poolerSpecHash"

	// OperatorManagedSecretsAnnotationName is the name of the annotation containing
	// the secrets managed by the operator inside the generated service account
	OperatorManagedSecretsAnnotationName = MetadataNamespace + "/managedSecrets"

	// FencedInstanceAnnotation is the annotation to be used for fencing instances, the value should be a
	// JSON list of all the instances we want to be fenced, e.g. `["cluster-example-1","cluster-example-2`"].
	// If the list contain the "*" element, every node is fenced.
	FencedInstanceAnnotation = MetadataNamespace + "/fencedInstances"

	// CNPGHashAnnotationName is the name of the annotation containing the hash of the resource used by operator
	// expect the pooler that uses PoolerSpecHashAnnotationName
	CNPGHashAnnotationName = MetadataNamespace + "/hash"

	// BackupStartWALAnnotationName is the name of the annotation where a backup's start WAL is kept
	BackupStartWALAnnotationName = MetadataNamespace + "/backupStartWAL"

	// BackupEndWALAnnotationName is the name of the annotation where a backup's end WAL is kept
	BackupEndWALAnnotationName = MetadataNamespace + "/backupEndWAL"

	// BackupStartTimeAnnotationName is the name of the annotation where a backup's start time is kept
	BackupStartTimeAnnotationName = MetadataNamespace + "/backupStartTime"

	// BackupEndTimeAnnotationName is the name of the annotation where a backup's end time is kept
	BackupEndTimeAnnotationName = MetadataNamespace + "/backupEndTime"

	// BackupLabelFileAnnotationName is the name of the annotation where the `backup_label` file is kept
	BackupLabelFileAnnotationName = MetadataNamespace + "/backupLabelFile"

	// BackupTablespaceMapFileAnnotationName is the name of the annotation where the `tablespace_map` file is kept
	BackupTablespaceMapFileAnnotationName = MetadataNamespace + "/backupTablespaceMapFile"

	// SnapshotStartTimeAnnotationName is the name of the annotation where a snapshot's start time is kept
	SnapshotStartTimeAnnotationName = MetadataNamespace + "/snapshotStartTime"

	// SnapshotEndTimeAnnotationName is the name of the annotation where a snapshot's end time is kept
	SnapshotEndTimeAnnotationName = MetadataNamespace + "/snapshotEndTime"

	// ClusterRestartAnnotationName is the name of the annotation containing the
	// latest required restart time
	ClusterRestartAnnotationName = "kubectl.kubernetes.io/restartedAt"
)
View Source
const (
	// PodHealthy means that a Pod is active and ready
	PodHealthy = "healthy"

	// PodReplicating means that a Pod is still not ready but still active
	PodReplicating = "replicating"

	// PodFailed means that a Pod will not be scheduled again (deleted or evicted)
	PodFailed = "failed"
)
View Source
const ContextKeyCluster contextKey = "cluster"

ContextKeyCluster is the context key holding cluster data

View Source
const (
	// FenceAllInstances is the wildcard that, if put inside the fenced instances list, will fence every
	// CNPG instance
	FenceAllInstances = "*"
)
View Source
const MetadataNamespace = "cnpg.io"

MetadataNamespace is the annotation and label namespace used by the operator

View Source
const (
	// PodReasonEvicted is set inside the status as the Pod failure reason
	// when the Kubelet evicts a Pod
	PodReasonEvicted = "Evicted"
)

Variables

View Source
var (
	// ErrorFencedInstancesSyntax is emitted when the fencedInstances annotation
	// have an invalid syntax
	ErrorFencedInstancesSyntax = errors.New("fencedInstances annotation has invalid syntax")

	// ErrorSingleInstanceUnfencing is emitted when unfencing a single instance
	// while all the cluster is fenced
	ErrorSingleInstanceUnfencing = errors.New("unfencing an instance while the whole cluster is fenced is not supported")
)
View Source
var ErrNextLoop = errors.New("stop this loop and return the associated Result object")

ErrNextLoop is not a real error. It forces the current reconciliation loop to stop and return the associated Result object

View Source
var ErrTerminateLoop = errors.New("stop this loop and do not requeue")

ErrTerminateLoop is not a real error. It forces the current reconciliation loop to stop

View Source
var ErrorContainerNotFound = fmt.Errorf("container not found")

ErrorContainerNotFound is raised when an Exec call is invoked against a non existing container

Functions

func AddFencedInstance

func AddFencedInstance(instanceName string, object metav1.Object) (bool, error)

AddFencedInstance adds the given server name to the FencedInstanceAnnotation annotation returns an error if the instance was already fenced

func AnnotateAppArmor

func AnnotateAppArmor(object *metav1.ObjectMeta, spec *corev1.PodSpec, annotations map[string]string)

AnnotateAppArmor adds an annotation to the pod

func CollectDifferencesFromMaps

func CollectDifferencesFromMaps(p1 map[string]string, p2 map[string]string) map[string][]string

CollectDifferencesFromMaps returns a map of the differences (as slice of strings) of the values of two given maps. Map result values are added when a key is present just in one of the input maps, or if the values are different given the same key

func ConvertToPostgresFormat

func ConvertToPostgresFormat(timestamp string) string

ConvertToPostgresFormat converts timestamps to PostgreSQL time format, if needed. e.g. "2006-01-02T15:04:05Z07:00" --> "2006-01-02 15:04:05.000000Z07:00" If the conversion fails, the input timestamp is returned as it is.

func CountJobsWithOneCompletion added in v1.17.4

func CountJobsWithOneCompletion(jobList []batchv1.Job) int

CountJobsWithOneCompletion count the number complete jobs

func CountReadyPods

func CountReadyPods(podList []corev1.Pod) int

CountReadyPods counts the number of Pods which are ready

func DetectAvailableArchitectures added in v1.21.4

func DetectAvailableArchitectures() error

DetectAvailableArchitectures detects the architectures available in the cluster

func DetectKubeSystemUID

func DetectKubeSystemUID(ctx context.Context, kubeClient client.Client) error

DetectKubeSystemUID retrieves the UID of the kube-system namespace of the containing cluster

func DetectSeccompSupport added in v1.16.4

func DetectSeccompSupport(client discovery.DiscoveryInterface) (err error)

DetectSeccompSupport checks the version of Kubernetes in the cluster to determine whether Seccomp is supported

func DetectSecurityContextConstraints

func DetectSecurityContextConstraints(client discovery.DiscoveryInterface) (err error)

DetectSecurityContextConstraints connects to the discovery API and find out if we're running under a system that implements OpenShift Security Context Constraints

func DetectVolumeSnapshotExist added in v1.21.0

func DetectVolumeSnapshotExist(client discovery.DiscoveryInterface) (err error)

DetectVolumeSnapshotExist connects to the discovery API and find out if the VolumeSnapshot CRD exist in the cluster

func DifferenceBetweenTimestamps added in v1.15.3

func DifferenceBetweenTimestamps(first, second string) (time.Duration, error)

DifferenceBetweenTimestamps returns the time.Duration difference between two timestamps strings in time.RFC3339.

func ExecCommand

func ExecCommand(
	ctx context.Context,
	client kubernetes.Interface,
	config *rest.Config,
	pod corev1.Pod,
	containerName string,
	timeout *time.Duration,
	command ...string,
) (string, string, error)

ExecCommand executes a command inside the pod, and returns its result

func FilterActivePods

func FilterActivePods(pods []corev1.Pod) []corev1.Pod

FilterActivePods returns pods that have not terminated.

func FilterJobsWithOneCompletion added in v1.17.4

func FilterJobsWithOneCompletion(jobList []batchv1.Job) []batchv1.Job

FilterJobsWithOneCompletion returns jobs that have one completion

func GetCurrentTimestamp

func GetCurrentTimestamp() string

GetCurrentTimestamp returns the current timestamp as a string in RFC3339Micro format

func GetCurrentTimestampWithFormat added in v1.18.3

func GetCurrentTimestampWithFormat(format string) string

GetCurrentTimestampWithFormat returns the current timestamp as a string with the specified format

func GetDiscoveryClient

func GetDiscoveryClient() (*discovery.DiscoveryClient, error)

GetDiscoveryClient creates a discovery client or return error

func GetFencedInstances

func GetFencedInstances(annotations map[string]string) (*stringset.Data, error)

GetFencedInstances gets the set of fenced servers from the annotations

func GetImageTag

func GetImageTag(imageName string) string

GetImageTag gets the image tag from a full image string. Example:

GetImageTag("postgres") == "latest"
GetImageTag("ghcr.io/cloudnative-pg/postgresql:12.3") == "12.3"

func GetInstanceRole added in v1.19.5

func GetInstanceRole(labels map[string]string) (string, bool)

GetInstanceRole tries to fetch the ClusterRoleLabelName andClusterInstanceRoleLabelName value from a given labels map

func GetKubeSystemUID

func GetKubeSystemUID() string

GetKubeSystemUID returns the uid of the kube-system namespace

func HaveSeccompSupport added in v1.16.4

func HaveSeccompSupport() bool

HaveSeccompSupport returns true if Seccomp is supported. If it is, we should set the SeccompProfile in the pods

func HaveSecurityContextConstraints

func HaveSecurityContextConstraints() bool

HaveSecurityContextConstraints returns true if we're running under a system that implements OpenShift Security Context Constraints It panics if called before DetectSecurityContextConstraints

func HaveVolumeSnapshot added in v1.21.0

func HaveVolumeSnapshot() bool

HaveVolumeSnapshot returns true if we're running under a system that implements having the VolumeSnapshot CRD

func InheritAnnotations

func InheritAnnotations(
	object *metav1.ObjectMeta,
	annotations map[string]string,
	fixedAnnotations map[string]string,
	controller InheritanceController,
)

InheritAnnotations puts into the object metadata the passed annotations if the annotations are supposed to be inherited. The passed configuration is used to determine whenever a certain annotation is inherited or not

func InheritLabels

func InheritLabels(
	object *metav1.ObjectMeta,
	labels map[string]string,
	fixedLabels map[string]string,
	controller InheritanceController,
)

InheritLabels puts into the object metadata the passed labels if the labels are supposed to be inherited. The passed configuration is used to determine whenever a certain label is inherited or not

func IsAnnotationAppArmorPresent

func IsAnnotationAppArmorPresent(spec *corev1.PodSpec, annotations map[string]string) bool

IsAnnotationAppArmorPresent checks if one of the annotations is an AppArmor annotation

func IsAnnotationAppArmorPresentInObject

func IsAnnotationAppArmorPresentInObject(
	object *metav1.ObjectMeta,
	spec *corev1.PodSpec,
	annotations map[string]string,
) bool

IsAnnotationAppArmorPresentInObject checks if the AppArmor annotations are present or not in the given Object

func IsAnnotationSubset

func IsAnnotationSubset(
	mapSet, clusterAnnotations, fixedInheritedAnnotations map[string]string,
	controller InheritanceController,
) bool

IsAnnotationSubset checks if a collection of annotations is a subset of another

NOTE: there are two parameters for the annotations to check. The `fixed` one is for annotations that certainly should be inherited (`inheritedMetadata` in the spec) The other annotations may or may not be inherited depending on the configuration

func IsConditionReasonValid added in v1.15.5

func IsConditionReasonValid(conditionReason string) bool

IsConditionReasonValid checks if a certain condition reason is valid or not given the Kubernetes API requirements

func IsEmptyWalArchiveCheckEnabled added in v1.16.4

func IsEmptyWalArchiveCheckEnabled(object *metav1.ObjectMeta) bool

IsEmptyWalArchiveCheckEnabled returns a boolean indicating if we should run the logic that checks if the WAL archive storage is empty

func IsLabelSubset

func IsLabelSubset(
	mapSet,
	clusterLabels,
	fixedInheritedLabels map[string]string,
	controller InheritanceController,
) bool

IsLabelSubset checks if a collection of labels is a subset of another

NOTE: there are two parameters for the labels to check. The `fixed` one is for labels that certainly should be inherited (`inheritedMetadata` in the spec) The other labels may or may not be inherited depending on the configuration

func IsMapSubset added in v1.19.5

func IsMapSubset(mapSet map[string]string, mapSubset map[string]string) bool

IsMapSubset returns true if mapSubset is a subset of mapSet otherwise false

func IsPodActive

func IsPodActive(p corev1.Pod) bool

IsPodActive checks if a pod is active, copied from: https://github.com/kubernetes/kubernetes/blob/1bd0077/test/e2e/framework/pod/resource.go#L664

func IsPodAlive

func IsPodAlive(p corev1.Pod) bool

IsPodAlive check if a pod is active and not crash-looping

func IsPodEvicted

func IsPodEvicted(p *corev1.Pod) bool

IsPodEvicted checks if a pod has been evicted by the Kubelet

func IsPodReady

func IsPodReady(pod corev1.Pod) bool

IsPodReady check if a Pod is ready or not

func IsPodUnscheduled added in v1.18.4

func IsPodUnscheduled(p *corev1.Pod) bool

IsPodUnscheduled check if a Pod is unscheduled

func IsPowerOfTwo

func IsPowerOfTwo(n int) bool

IsPowerOfTwo calculates if a number is power of two or not reference: https://github.com/golang/go/blob/master/src/strconv/itoa.go#L204 #wokeignore:rule=master This function will return false if the number is zero

func IsReconciliationDisabled

func IsReconciliationDisabled(object *metav1.ObjectMeta) bool

IsReconciliationDisabled checks if the reconciliation loop is disabled on the given resource

func IsWalArchivingDisabled added in v1.21.4

func IsWalArchivingDisabled(object *metav1.ObjectMeta) bool

IsWalArchivingDisabled returns a boolean indicating if PostgreSQL not archive WAL files

func JobHasOneCompletion added in v1.18.4

func JobHasOneCompletion(job batchv1.Job) bool

JobHasOneCompletion Completion check if a certain job is complete

func LabelClusterName

func LabelClusterName(object *metav1.ObjectMeta, name string)

LabelClusterName labels the object with the cluster name

func ListStatusPods

func ListStatusPods(podList []corev1.Pod) map[PodStatus][]string

ListStatusPods return a list of active Pods

func MapToBarmanTagsFormat

func MapToBarmanTagsFormat(option string, mapTags map[string]string) ([]string, error)

MapToBarmanTagsFormat will transform a map[string]string into the Barman tags format needed

func MergeMap added in v1.18.1

func MergeMap(receiver, giver map[string]string)

MergeMap transfers the content of a giver map to a receiver ensure the receiver is not nil before call this method

func MergeObjectsMetadata added in v1.20.5

func MergeObjectsMetadata(receiver client.Object, giver client.Object)

MergeObjectsMetadata is capable of merging the labels and annotations of two objects metadata

func ParsePgControldataOutput added in v1.21.0

func ParsePgControldataOutput(data string) map[string]string

ParsePgControldataOutput parses a pg_controldata output into a map of key-value pairs

func ParsePolicy

func ParsePolicy(policy string) (string, error)

ParsePolicy ensure that the policy string follows the rules required by Barman

func ParseTargetTime

func ParseTargetTime(currentLocation *time.Location, targetTime string) (time.Time, error)

ParseTargetTime returns the parsed targetTime which is used for point-in-time-recovery Currently, we support formats of targetTime as follows: YYYY-MM-DD HH24:MI:SS YYYY-MM-DD HH24:MI:SS.FF6TZH YYYY-MM-DD HH24:MI:SS.FF6TZH:TZM YYYY-MM-DDTHH24:MI:SSZ (time.RFC3339) YYYY-MM-DDTHH24:MI:SS±TZH:TZM (time.RFC3339) YYYY-MM-DDTHH24:MI:SSS±TZH:TZM (time.RFC3339Micro) YYYY-MM-DDTHH24:MI:SS (modified time.RFC3339)

func PodMonitorExist

func PodMonitorExist(client discovery.DiscoveryInterface) (bool, error)

PodMonitorExist tries to find the PodMonitor resource in the current cluster

func SetAsOwnedBy

func SetAsOwnedBy(controlled *v1.ObjectMeta, controller v1.ObjectMeta, typeMeta v1.TypeMeta)

SetAsOwnedBy sets the controlled object as owned by a certain other controller object with his type information

func SetInstanceRole added in v1.19.5

func SetInstanceRole(meta metav1.ObjectMeta, role string)

SetInstanceRole sets both ClusterRoleLabelName and ClusterInstanceRoleLabelName on the given ObjectMeta

func SetOperatorVersion

func SetOperatorVersion(object *metav1.ObjectMeta, version string)

SetOperatorVersion set inside a certain object metadata the annotation containing the version of the operator that generated the object

func SetSeccompSupport added in v1.18.4

func SetSeccompSupport(value bool)

SetSeccompSupport set the supportSeccomp variable to a specific value for testing purposes

func SetVolumeSnapshot added in v1.21.0

func SetVolumeSnapshot(value bool)

SetVolumeSnapshot set the haveVolumeSnapshot variable to a specific value for testing purposes IMPORTANT: use it only in the unit tests

func StringInSlice

func StringInSlice(slice []string, search string) bool

StringInSlice looks for a search string inside the string slice

func ToBytes added in v1.18.2

func ToBytes[T constraints.Signed | constraints.Float](mb T) float64

ToBytes converts an input value in MB to bytes Input: value - an integer representing size in MB Output: the size in bytes, calculated by multiplying the input value by 1024 * 1024

func ToCompactISO8601 added in v1.21.0

func ToCompactISO8601(t time.Time) string

ToCompactISO8601 converts a time.Time into a compacted version of the ISO8601 timestamp, removing any separators for brevity.

For example:

Given: 2022-01-02 15:04:05 (UTC)
Returns: 20220102150405

This compact format is useful for generating concise, yet human-readable timestamps that can serve as suffixes for backup-related objects or any other contexts where space or character count might be a concern.

Types

type AvailableArchitecture added in v1.21.4

type AvailableArchitecture struct {
	GoArch string
	// contains filtered or unexported fields
}

AvailableArchitecture is a struct containing info about an available architecture

func GetAvailableArchitecture added in v1.21.4

func GetAvailableArchitecture(goArch string) (*AvailableArchitecture, error)

GetAvailableArchitecture returns an available architecture given its goArch

func GetAvailableArchitectures added in v1.21.4

func GetAvailableArchitectures() []*AvailableArchitecture

GetAvailableArchitectures returns the available instance's architectures

func (*AvailableArchitecture) FileStream added in v1.21.4

func (arch *AvailableArchitecture) FileStream() (io.ReadCloser, error)

FileStream opens a stream reading from the manager's binary

func (*AvailableArchitecture) GetHash added in v1.21.4

func (arch *AvailableArchitecture) GetHash() string

GetHash retrieves the hash for a given AvailableArchitecture

type FencingMetadataExecutor added in v1.21.5

type FencingMetadataExecutor struct {
	// contains filtered or unexported fields
}

FencingMetadataExecutor executes the logic regarding adding and removing the fencing annotation for a kubernetes object

func NewFencingMetadataExecutor added in v1.21.5

func NewFencingMetadataExecutor(cli client.Client) *FencingMetadataExecutor

NewFencingMetadataExecutor creates a fluent client for FencingMetadataExecutor

func (*FencingMetadataExecutor) AddFencing added in v1.21.5

AddFencing instructs the client to execute the logic of adding a instance

func (*FencingMetadataExecutor) Execute added in v1.21.5

Execute executes the instructions given with the fluent builder, returns any error encountered

func (*FencingMetadataExecutor) ForAllInstances added in v1.21.5

func (fb *FencingMetadataExecutor) ForAllInstances() *FencingMetadataExecutor

ForAllInstances applies the logic to all cluster instances

func (*FencingMetadataExecutor) ForInstance added in v1.21.5

func (fb *FencingMetadataExecutor) ForInstance(instanceName string) *FencingMetadataExecutor

ForInstance applies the logic to the specified instance

func (*FencingMetadataExecutor) RemoveFencing added in v1.21.5

func (fb *FencingMetadataExecutor) RemoveFencing() *FencingMetadataExecutor

RemoveFencing instructs the client to execute the logic of removing an instance

type HibernationAnnotationValue added in v1.21.4

type HibernationAnnotationValue string

HibernationAnnotationValue describes the status of the hibernation

const (
	// HibernationAnnotationValueOff is the value of hibernation annotation when the hibernation
	// has been deactivated for the cluster
	HibernationAnnotationValueOff HibernationAnnotationValue = "off"

	// HibernationAnnotationValueOn is the value of hibernation annotation when the hibernation
	// has been requested for the cluster
	HibernationAnnotationValueOn HibernationAnnotationValue = "on"
)

type InheritanceController added in v1.18.4

type InheritanceController interface {
	// IsAnnotationInherited checks if a certain annotation should be
	// inherited
	IsAnnotationInherited(name string) bool

	// IsLabelInherited checks if a certain label should be
	// inherited
	IsLabelInherited(name string) bool
}

InheritanceController controls if a label or an annotation should be inherited

type PVCRole added in v1.17.0

type PVCRole string

PVCRole describes the role of a PVC

const (
	// PVCRolePgData the label value for the data PVC role
	PVCRolePgData PVCRole = "PG_DATA"
	// PVCRolePgWal the label value for the wal PVC role
	PVCRolePgWal PVCRole = "PG_WAL"
	// PVCRolePgTablespace the label value for the tablespace PVC role
	PVCRolePgTablespace PVCRole = "PG_TABLESPACE"
)

type PodRole added in v1.15.4

type PodRole string

PodRole describes the Role of a given pod

const (
	// PodRoleInstance the label value indicating an instance
	PodRoleInstance PodRole = "instance"
	// PodRolePooler the label value indicating a pooler instance
	PodRolePooler PodRole = "pooler"
)

type PodStatus

type PodStatus string

PodStatus represent the possible status of pods

type Reference

type Reference struct {
	Name   string
	Tag    string
	Digest string
}

Reference .

func NewReference

func NewReference(name string) *Reference

NewReference parses the image name and returns an error if the name is invalid.

func (*Reference) GetNormalizedName

func (r *Reference) GetNormalizedName() (name string)

GetNormalizedName returns the normalized name of a reference

Directories

Path Synopsis
Package hash allows the user to get a hash number for a given Kubernetes object.
Package hash allows the user to get a hash number for a given Kubernetes object.
Package logs contains code to fetch logs from Kubernetes pods
Package logs contains code to fetch logs from Kubernetes pods

Jump to

Keyboard shortcuts

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