util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FalseVar = false
View Source
var TrueVar = true

Functions

func AddOwnerRefToObject

func AddOwnerRefToObject(obj metav1.Object, ownerRef metav1.OwnerReference)

AddOwnerRefToObject appends the desired OwnerReference to the object

func AsOwner

AsOwner returns an OwnerReference set as the PerconaServerMongoDB CR

func DeletePersistentVolumeClaim

func DeletePersistentVolumeClaim(client sdk.Client, m *v1alpha1.PerconaServerMongoDB, pvcName string) error

DeletePersistentVolumeClaim deletes a Persistent Volume Claim

func EnvVarSourceFromSecret

func EnvVarSourceFromSecret(name, key string) *corev1.EnvVarSource

EnvVarSourceFromSecret returns an corev1.EnvVarSource based on a secret key

func GetContainerResourceRequirements

func GetContainerResourceRequirements(reqs corev1.ResourceRequirements) corev1.ResourceRequirements

GetContainerResourceRequirements returns a corev1.ResourceRequirements with the 'storage' type (not needed in corev1.Container) removed

func GetContainerRunUID

func GetContainerRunUID(m *v1alpha1.PerconaServerMongoDB, serverVersion *v1alpha1.ServerVersion) *int64

GetContainerRunUID returns an int64-pointer reflecting the user ID a container should run as

func GetLabelSelectorListOpts

func GetLabelSelectorListOpts(m *v1alpha1.PerconaServerMongoDB, replset *v1alpha1.ReplsetSpec) *metav1.ListOptions

GetLabelSelectorListOpts returns metav1.ListOptions with a label-selector for a given replset

func GetPersistentVolumeClaims

func GetPersistentVolumeClaims(client sdk.Client, m *v1alpha1.PerconaServerMongoDB, replset *v1alpha1.ReplsetSpec) ([]corev1.PersistentVolumeClaim, error)

GetPersistentVolumeClaims returns a list of Persistent Volume Claims for a given replset

func GetPlatform

func GetPlatform(m *v1alpha1.PerconaServerMongoDB, serverVersion *v1alpha1.ServerVersion) v1alpha1.Platform

GetPlatform returns the Kubernetes platform type, first using the Spec 'platform' field or the serverVersion.Platform field if the Spec 'platform' field is not set

func GetPodContainer

func GetPodContainer(pod *corev1.Pod, containerName string) *corev1.Container

GetPodContainer returns a container, if it exists

func GetPodContainerStatus

func GetPodContainerStatus(status *corev1.PodStatus, containerName string) *corev1.ContainerStatus

GetPodContainerStatus returns a container status from a pod status, if it exists

func GetPodNames

func GetPodNames(pods []corev1.Pod) []string

GetPodNames returns the pod names of the array of pods passed in

func GetPodSpecContainer

func GetPodSpecContainer(spec *corev1.PodSpec, containerName string) *corev1.Container

GetPodSpecContainer returns a container from a pod spec, if it exists

func GetSecret

func GetSecret(m *v1alpha1.PerconaServerMongoDB, client sdk.Client, secretName string) (*corev1.Secret, error)

GetSecret retrieves a Kubernetes Secret

func GetServerVersion

func GetServerVersion() (*v1alpha1.ServerVersion, error)

GetServerVersion returns server version and platform (k8s|oc) stolen from: https://github.com/openshift/origin/blob/release-3.11/pkg/oc/cli/version/version.go#L106

func IsContainerAndPodRunning

func IsContainerAndPodRunning(pod corev1.Pod, containerName string) bool

IsContainerAndPodRunning returns a boolean reflecting if a container and pod are in a running state

func IsContainerTerminated

func IsContainerTerminated(podStatus *corev1.PodStatus, containerName string) (bool, error)

IsContainerTerminated returns a boolean reflecting if a container has terminated

func IsPodReady

func IsPodReady(pod corev1.Pod) bool

IsPodReady returns a boolean reflecting if a pod is in a "ready" state

func IsStatefulSetUpdating

func IsStatefulSetUpdating(set *appsv1.StatefulSet) bool

IsStatefulSetUpdating returns a boolean reflecting if a StatefulSet is updating or scaling. If the currentRevision is different than the updateRevision or if the number of readyReplicas is different than currentReplicas, the set is updating

func LabelsForPerconaServerMongoDB

func LabelsForPerconaServerMongoDB(m *v1alpha1.PerconaServerMongoDB, labels map[string]string) map[string]string

LabelsForPerconaServerMongoDB returns the labels for selecting the resources belonging to the given PerconaServerMongoDB CR name.

func LabelsForPerconaServerMongoDBReplset

func LabelsForPerconaServerMongoDBReplset(m *v1alpha1.PerconaServerMongoDB, replset *v1alpha1.ReplsetSpec) map[string]string

LabelsForPerconaServerMongoDBReplset returns the labels for selecting the resources belonging to the given PerconaServerMongoDB Replset.

func NewPersistentVolumeClaim

func NewPersistentVolumeClaim(m *v1alpha1.PerconaServerMongoDB, resources corev1.ResourceRequirements, claimName, storageClass string) corev1.PersistentVolumeClaim

NewPersistentVolumeClaim returns a Persistent Volume Claims for Mongod pod

func NewSecret

func NewSecret(m *v1alpha1.PerconaServerMongoDB, name string, data map[string]string) *corev1.Secret

NewSecret returns a Core API Secret structure

func NewStatefulSet

func NewStatefulSet(m *v1alpha1.PerconaServerMongoDB, name string) *appsv1.StatefulSet

NewStatefulSet returns a StatefulSet object configured for a name

func ParseResourceSpecRequirements

func ParseResourceSpecRequirements(specLimits, specRequests *v1alpha1.ResourceSpecRequirements) (corev1.ResourceRequirements, error)

ParseResourceSpecRequirements parses the resource section of the spec to a corev1.ResourceRequirements object

func PodList

func PodList() *corev1.PodList

PodList returns a v1.PodList object

func ReplsetStatusHasPod

func ReplsetStatusHasPod(status *v1alpha1.ReplsetStatus, podName string) bool

ReplsetStatusHasPod returns a boolean reflecting if a ReplsetSTatus contains a pod name

Types

This section is empty.

Jump to

Keyboard shortcuts

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