utils

package
v0.0.0-...-12c90d4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DockerHubImagePrefix = "docker.io/"

	// ReasonImagePullBackOff when pod status is Pending as container image pull failed.
	ReasonImagePullBackOff = "ImagePullBackOff"
	// ReasonImageInspectError is error inspecting image.
	ReasonImageInspectError = "ImageInspectError"
	// ReasonErrImagePull is general image pull error.
	ReasonErrImagePull = "ErrImagePull"
	// ReasonRegistryUnavailable is the http error when pulling image from registry.
	ReasonRegistryUnavailable = "RegistryUnavailable"
)

Variables

This section is empty.

Functions

func CheckPodFailed

func CheckPodFailed(pod *corev1.Pod) error

CheckPodFailed checks if pod has failed or has terminated or is in an irrecoverable waiting state.

func CheckPodImageFailed

func CheckPodImageFailed(pod *corev1.Pod) error

CheckPodImageFailed checks if pod has failed or has terminated or is in an irrecoverable waiting state due to an image related error.

func ClusterNamespacedName

func ClusterNamespacedName(aeroCluster *asdbv1.AerospikeCluster) string

ClusterNamespacedName return namespaced name

func ContainsString

func ContainsString(slice []string, s string) bool

ContainsString returns true if a string exists in a slice of strings.

func Exec

func Exec(podNamespacedName types.NamespacedName, container string, cmd []string, kubeClient *kubernetes.Clientset,
	kubeConfig *rest.Config) (stdoutStr, stderrStr string, err error)

Exec executes a non interactive command on a pod.

func GetDesiredImage

func GetDesiredImage(
	aeroCluster *asdbv1.AerospikeCluster, containerName string,
) (string, error)

GetDesiredImage returns the desired image for the input containerName from the aeroCluster spec.

func GetHash

func GetHash(str string) (string, error)

GetHash return ripemd160 hash for given string

func GetNamespacedName

func GetNamespacedName(obj meta.Object) types.NamespacedName

func GetNamespacedNameForSTSOrConfigMap

func GetNamespacedNameForSTSOrConfigMap(
	aeroCluster *asdbv1.AerospikeCluster, rackID int,
) types.NamespacedName

func GetRackIDFromPodName

func GetRackIDFromPodName(podName string) (*int, error)

GetRackIDFromPodName returns the rack id given a pod name.

func GetRackIDFromSTSName

func GetRackIDFromSTSName(statefulSetName string) (*int, error)

func IsImageEqual

func IsImageEqual(image1, image2 string) bool

IsImageEqual returns true if image name image1 is equal to image name image2.

func IsPVCTerminating

func IsPVCTerminating(pvc *corev1.PersistentVolumeClaim) bool

IsPVCTerminating returns true if pvc's DeletionTimestamp has been set

func IsPodReasonUnschedulable

func IsPodReasonUnschedulable(pod *corev1.Pod) (isPodUnschedulable bool, reason string)

func IsPodRunningAndReady

func IsPodRunningAndReady(pod *corev1.Pod) bool

IsPodRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady. TODO: check if its is properly running, error crashLoop also passed in this

func IsPodTerminating

func IsPodTerminating(pod *corev1.Pod) bool

IsPodTerminating returns true if pod's DeletionTimestamp has been set

func LabelsForAerospikeBackupService

func LabelsForAerospikeBackupService(clName string) map[string]string

LabelsForAerospikeBackupService returns the labels for selecting the resources belonging to the given AerospikeBackupService CR name.

func LabelsForAerospikeCluster

func LabelsForAerospikeCluster(clName string) map[string]string

LabelsForAerospikeCluster returns the labels for selecting the resources belonging to the given AerospikeCluster CR name.

func LabelsForAerospikeClusterRack

func LabelsForAerospikeClusterRack(
	clName string, rackID int,
) map[string]string

LabelsForAerospikeClusterRack returns the labels for specific rack

func LabelsForPodAntiAffinity

func LabelsForPodAntiAffinity(clName string) map[string]string

LabelsForPodAntiAffinity returns the labels to use for setting pod anti-affinity.

func MergeLabels

func MergeLabels(operatorLabels, userLabels map[string]string) map[string]string

MergeLabels merges operator an user defined labels

func NamespacedName

func NamespacedName(namespace, name string) string

NamespacedName return namespaced name

func ParseDockerImageTag

func ParseDockerImageTag(tag string) (
	registry string, name string, version string,
)

ParseDockerImageTag parses input tag into registry, name and version.

func RemoveString

func RemoveString(slice []string, s string) (result []string)

RemoveString removes a string from a slice of strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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