utils

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LastAppliedConfigAnnotation is annotation key of last applied configuration
	LastAppliedConfigAnnotation = "pingcap.com/last-applied-configuration"
)

Variables

This section is empty.

Functions

func AddConfigMapDigestSuffix

func AddConfigMapDigestSuffix(cm *corev1.ConfigMap) error

func FindConfigMapVolume

func FindConfigMapVolume(podSpec *corev1.PodSpec, pred func(string) bool) string

FindConfigMapVolume returns the configmap which's name matches the predicate in a PodSpec, empty indicates not found

func SetStatefulSetLastAppliedConfigAnnotation

func SetStatefulSetLastAppliedConfigAnnotation(set *apps.StatefulSet) error

SetStatefulSetLastAppliedConfigAnnotation set last applied config to Statefulset's annotation

func SetUpgradePartition

func SetUpgradePartition(set *apps.StatefulSet, upgradeOrdinal int32)

SetUpgradePartition set statefulSet's rolling update partition

func Sha256Sum

func Sha256Sum(v interface{}) (string, error)

func StatefulSetIsUpgrading

func StatefulSetIsUpgrading(set *apps.StatefulSet) bool

StatefulSetIsUpgrading confirms whether the statefulSet is upgrading phase

func UpdateConfigMapIfNeed

func UpdateConfigMapIfNeed(
	cmLister corelisters.ConfigMapLister,
	configUpdateStrategy v1alpha1.ConfigUpdateStrategy,
	inUseName string,
	desired *corev1.ConfigMap,
) error

UpdateConfigMapIfNeed set the toml field as the old one if they are logically equal.

func UpdateStatefulSet

func UpdateStatefulSet(setCtl controller.StatefulSetControlInterface, object runtime.Object, newSet, oldSet *apps.StatefulSet) error

UpdateStatefulSet is a template function to update the statefulset of components

func UpdateStatefulSetWithPrecheck

func UpdateStatefulSetWithPrecheck(
	deps *controller.Dependencies,
	tc *v1alpha1.TidbCluster,
	reason string,
	newTiDBSet *apps.StatefulSet,
	oldTiDBSet *apps.StatefulSet,
) error

Types

type ContainerBuilder

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

func NewContainerBuilder

func NewContainerBuilder(container *corev1.Container) *ContainerBuilder

func (*ContainerBuilder) AddEnvFroms added in v1.3.5

func (cb *ContainerBuilder) AddEnvFroms(envFroms ...corev1.EnvFromSource)

func (*ContainerBuilder) AddEnvs

func (cb *ContainerBuilder) AddEnvs(envs ...corev1.EnvVar)

func (*ContainerBuilder) AddVolumeMounts

func (cb *ContainerBuilder) AddVolumeMounts(mounts ...corev1.VolumeMount)

func (*ContainerBuilder) Clone

func (cb *ContainerBuilder) Clone() *corev1.Container

func (*ContainerBuilder) Get

func (cb *ContainerBuilder) Get() *corev1.Container

type PodTemplateSpecBuilder

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

func NewPodTemplateSpecBuilder

func NewPodTemplateSpecBuilder(podTemplate *corev1.PodTemplateSpec) *PodTemplateSpecBuilder

func (*PodTemplateSpecBuilder) AddAnnotations

func (b *PodTemplateSpecBuilder) AddAnnotations(annos map[string]string)

func (*PodTemplateSpecBuilder) AddContainers

func (pb *PodTemplateSpecBuilder) AddContainers(containers ...corev1.Container)

AddContainers add container to pod's spec

NOTE: if container slice expand, old ContainerBuilder reference will be outdated.

func (*PodTemplateSpecBuilder) AddLabels

func (b *PodTemplateSpecBuilder) AddLabels(labels map[string]string)

func (*PodTemplateSpecBuilder) AddVolumes

func (b *PodTemplateSpecBuilder) AddVolumes(volumes ...corev1.Volume)

func (*PodTemplateSpecBuilder) Clone

func (*PodTemplateSpecBuilder) ContainerBuilder

func (pb *PodTemplateSpecBuilder) ContainerBuilder(name string) *ContainerBuilder

ContainerBuilder return the specified container builder

NOTE: don't save the builder, it will be outdated if container slice expand

func (*PodTemplateSpecBuilder) Get

type StatefulSetBuilder

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

func NewStatefulSetBuilder

func NewStatefulSetBuilder(sts *apps.StatefulSet) *StatefulSetBuilder

func (*StatefulSetBuilder) AddVolumeClaims

func (sb *StatefulSetBuilder) AddVolumeClaims(pvcs ...corev1.PersistentVolumeClaim)

func (*StatefulSetBuilder) Clone

func (sb *StatefulSetBuilder) Clone() *apps.StatefulSet

func (*StatefulSetBuilder) Get

func (sb *StatefulSetBuilder) Get() *apps.StatefulSet

func (*StatefulSetBuilder) PodTemplateSpecBuilder

func (sb *StatefulSetBuilder) PodTemplateSpecBuilder() *PodTemplateSpecBuilder

Jump to

Keyboard shortcuts

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