util

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigMapPrefix = "yurt-static-set-"

	// PodNeedUpgrade indicates whether the pod is able to upgrade.
	PodNeedUpgrade corev1.PodConditionType = "PodNeedUpgrade"

	StaticPodHashAnnotation = "openyurt.io/static-pod-hash"
)

Variables

View Source
var (
	PodGVK = corev1.SchemeGroupVersion.WithKind("Pod")
)

Functions

func ComputeHash

func ComputeHash(template *corev1.PodTemplateSpec) string

ComputeHash returns a hash value calculated from pod template

func DeepHashObject

func DeepHashObject(hasher hash.Hash, objectToWrite interface{})

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.

func GenStaticPodManifest

func GenStaticPodManifest(tmplSpec *corev1.PodTemplateSpec, hash string) (string, error)

GenStaticPodManifest generates manifest from use-specified template

func GetNodeCondition

func GetNodeCondition(status *corev1.NodeStatus, conditionType corev1.NodeConditionType) (int, *corev1.NodeCondition)

GetNodeCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodCondition

func GetPodCondition(status *corev1.PodStatus, conditionType corev1.PodConditionType) (int, *corev1.PodCondition)

GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodConditionFromList

func GetPodConditionFromList(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) (int, *corev1.PodCondition)

GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.

func Hyphen

func Hyphen(str1, str2 string) string

func IsStaticPod

func IsStaticPod(pod *corev1.Pod) bool

IsStaticPod judges whether a pod is static by its OwnerReference

func NodeReadyByName

func NodeReadyByName(c client.Client, nodeName string) (bool, error)

NodeReadyByName check if the given node is ready

func SetPodUpgradeCondition

func SetPodUpgradeCondition(c client.Client, status corev1.ConditionStatus, pod *corev1.Pod) error

SetPodUpgradeCondition set pod condition `PodNeedUpgrade` to the specified value

func UnavailableCount

func UnavailableCount(us *appsv1alpha1.YurtStaticSetUpgradeStrategy, numberToUpgrade int) (int, error)

UnavailableCount returns 0 if unavailability is not requested, the expected unavailability number to allow out of numberToUpgrade if requested, or an error if the unavailability percentage requested is invalid.

func UpdatePodCondition

func UpdatePodCondition(status *corev1.PodStatus, condition *corev1.PodCondition) bool

UpdatePodCondition updates existing pod condition or creates a new one. Sets LastTransitionTime to now if the status has changed. Returns true if pod condition has changed or has been added.

func WithConfigMapPrefix

func WithConfigMapPrefix(str string) string

WithConfigMapPrefix add prefix `yurt-static-set-` to the given string

Types

This section is empty.

Jump to

Keyboard shortcuts

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