util

package
v0.0.0-...-848b2d1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualIgnoreHash

func EqualIgnoreHash(template1, template2 *v1.PodTemplateSpec) bool

EqualIgnoreHash returns true if two given podTemplateSpec are equal, ignoring the diff in value of Labels[pod-template-hash] We ignore pod-template-hash because:

  1. The hash result would be different upon podTemplateSpec API changes (e.g. the addition of a new field will cause the hash code to change)
  2. The deployment template won't have hash labels

func FindNewReplicaSet

func FindNewReplicaSet(deployment *appsv1.Deployment, rsList []*appsv1.ReplicaSet) *appsv1.ReplicaSet

func GetScaledValueFromIntOrPercent

func GetScaledValueFromIntOrPercent(intOrPercent *intstrutil.IntOrString, total int, roundUp bool) (int, error)

GetScaledValueFromIntOrPercent is meant to replace GetValueFromIntOrPercent. This method returns a scaled value from an IntOrString type. If the IntOrString is a percentage string value it's treated as a percentage and scaled appropriately in accordance to the total, if it's an int value it's treated as a a simple value and if it is a string value which is either non-numeric or numeric but lacking a trailing '%' it returns an error.

func IsRollingUpdate

func IsRollingUpdate(deployment *appsv1.Deployment) bool

IsRollingUpdate returns true if the strategy type is a rolling update.

func MaxUnavailable

func MaxUnavailable(deployment appsv1.Deployment) int32

MaxUnavailable returns the maximum unavailable pods a rolling deployment can take.

func ResolveFenceposts

func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error)

ResolveFenceposts resolves both maxSurge and maxUnavailable. This needs to happen in one step. For example:

2 desired, max unavailable 1%, surge 0% - should scale old(-1), then new(+1), then old(-1), then new(+1) 1 desired, max unavailable 1%, surge 0% - should scale old(-1), then new(+1) 2 desired, max unavailable 25%, surge 1% - should scale new(+1), then old(-1), then new(+1), then old(-1) 1 desired, max unavailable 25%, surge 1% - should scale new(+1), then old(-1) 2 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1), then new(+1), then old(-1) 1 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1)

Types

type ReplicaSetsByCreationTimestamp

type ReplicaSetsByCreationTimestamp []*appsv1.ReplicaSet

ReplicaSetsByCreationTimestamp sorts a list of ReplicaSet by creation timestamp, using their names as a tie breaker.

func (ReplicaSetsByCreationTimestamp) Len

func (ReplicaSetsByCreationTimestamp) Less

func (ReplicaSetsByCreationTimestamp) Swap

func (o ReplicaSetsByCreationTimestamp) Swap(i, j int)

Jump to

Keyboard shortcuts

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