replicaset

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EphemeralMetadataAnnotation denotes pod metadata which are ephemerally injected to canary/stable pods
	EphemeralMetadataAnnotation = "rollout-ephemeral-metadata"
)

Variables

This section is empty.

Functions

func AllDesiredAreAvailable

func AllDesiredAreAvailable(rs *appsv1.ReplicaSet, desired int32) bool

func AtDesiredReplicaCountsForCanary

func AtDesiredReplicaCountsForCanary(ro *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, otherRSs []*appsv1.ReplicaSet) bool

func CalculateReplicaCountsForBasicCanary

func CalculateReplicaCountsForBasicCanary(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, stableRS *appsv1.ReplicaSet, otherRSs []*appsv1.ReplicaSet) (int32, int32)

func CheckPodSpecChange

func CheckPodSpecChange(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet) bool

CheckPodSpecChange checkPodSpecChange indicates if the rollout spec has changed indicating that the rollout needs to reset the currentStepIndex to zero. If there is no previous pod spec to compare to the function defaults to false

func CheckStableRSExists

func CheckStableRSExists(newRS, stableRS *appsv1.ReplicaSet) bool

CheckStableRSExists checks if the stableRS exists and is different than the newRS

func CreateInjectedAntiAffinityRule

func CreateInjectedAntiAffinityRule(rollout v1alpha1.Rollout) corev1.PodAffinityTerm

func FindActiveOrLatest

func FindActiveOrLatest(newRS *appsv1.ReplicaSet, oldRSs []*appsv1.ReplicaSet) *appsv1.ReplicaSet

FindActiveOrLatest returns the only active or the latest replica set in case there is at most one active replica set. If there are more active replica sets, then we should proportionally scale them.

func FindNewReplicaSet

func FindNewReplicaSet(rollout *v1alpha1.Rollout, rsList []*appsv1.ReplicaSet) *appsv1.ReplicaSet

FindNewReplicaSet 找新 RS 列表, 一般来说,通过 podTemplateHash作为label来匹配

func FindOldReplicaSets

func FindOldReplicaSets(rollout *v1alpha1.Rollout, rsList []*appsv1.ReplicaSet, newRS *appsv1.ReplicaSet) []*appsv1.ReplicaSet

FindOldReplicaSets returns the old replica sets targeted by the given Rollout, with the given slice of RSes. 除了新的,全都是老的,包括 stable 的

func GenerateReplicaSetAffinity

func GenerateReplicaSetAffinity(rollout v1alpha1.Rollout) *corev1.Affinity

func GetActualReplicaCountForReplicaSets

func GetActualReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32

GetActualReplicaCountForReplicaSets 返回所有 所有RS的实际副本数

func GetAvailableReplicaCountForReplicaSets

func GetAvailableReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32

GetAvailableReplicaCountForReplicaSets returns the number of available pods corresponding to the given replica sets.

func GetCanaryReplicasOrWeight

func GetCanaryReplicasOrWeight(rollout *v1alpha1.Rollout) (*int32, int32)

GetCanaryReplicasOrWeight either returns a static set of replicas or a weight percentage

func GetCurrentCanaryStep

func GetCurrentCanaryStep(rollout *v1alpha1.Rollout) (*v1alpha1.CanaryStep, *int32)

GetCurrentCanaryStep returns the current canary step. If there are no steps or the rollout has already executed the last step, the func returns nil

func GetCurrentSetWeight

func GetCurrentSetWeight(rollout *v1alpha1.Rollout) int32

GetCurrentSetWeight grabs the current setWeight used by the rollout by iterating backwards from the current step until it finds a setWeight step. The controller defaults to 100 if it iterates through all the steps with no setWeight or if there is no current step (i.e. the controller has already stepped through all the steps).

func GetOtherRSs

func GetOtherRSs(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, allRSs []*appsv1.ReplicaSet) []*appsv1.ReplicaSet

GetOtherRSs the function goes through a list of ReplicaSets and returns a list of RS that are not the new or stable RS

func GetPodTemplateHash

func GetPodTemplateHash(rs *appsv1.ReplicaSet) string

GetPodTemplateHash returns the rollouts-pod-template-hash value from a ReplicaSet's labels

func GetPodsOwnedByReplicaSet

func GetPodsOwnedByReplicaSet(ctx context.Context, client kubernetes.Interface, rs *appsv1.ReplicaSet) ([]*corev1.Pod, error)

GetPodsOwnedByReplicaSet returns a list of pods owned by the given replicaset

func GetReadyReplicaCountForReplicaSets

func GetReadyReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32

GetReadyReplicaCountForReplicaSets returns the number of ready pods corresponding to the given replica sets.

func GetReplicaCountForReplicaSets

func GetReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32

GetReplicaCountForReplicaSets returns the sum of Replicas of the given replica sets.

func GetReplicaSetRevision

func GetReplicaSetRevision(ro *v1alpha1.Rollout, rs *appsv1.ReplicaSet) int

func GetRolloutAffinity

func GetRolloutAffinity(rollout v1alpha1.Rollout) *v1alpha1.AntiAffinity

func GetStableRS

func GetStableRS(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, rslist []*appsv1.ReplicaSet) *appsv1.ReplicaSet

GetStableRS finds the stable RS using the RS's RolloutUniqueLabelKey and the stored StableRS in the rollout status

func GetTimeRemainingBeforeScaleDownDeadline

func GetTimeRemainingBeforeScaleDownDeadline(rs *appsv1.ReplicaSet) (*time.Duration, error)

func HasInjectedAntiAffinityRule

func HasInjectedAntiAffinityRule(affinity *corev1.Affinity, rollout v1alpha1.Rollout) (int, *corev1.PodAffinityTerm)

func HasScaleDownDeadline

func HasScaleDownDeadline(rs *appsv1.ReplicaSet) bool

HasScaleDownDeadline returns whether or not the given ReplicaSet is annotated with a scale-down delay

func IfInjectedAntiAffinityRuleNeedsUpdate

func IfInjectedAntiAffinityRuleNeedsUpdate(affinity *corev1.Affinity, rollout v1alpha1.Rollout) bool

func IsReplicaSetAvailable

func IsReplicaSetAvailable(rs *appsv1.ReplicaSet) bool

IsReplicaSetAvailable returns if a ReplicaSet is scaled up and its ready count is >= desired count 当前 RS 是否 ready

func IsStillReferenced

func IsStillReferenced(status v1alpha1.RolloutStatus, rs *appsv1.ReplicaSet) bool

IsStillReferenced returns if the given ReplicaSet is still being referenced by any of the current, stable, blue-green active references. Used to determine if the ReplicaSet can safely be scaled to zero, or deleted.

func MaxRevision

func MaxRevision(allRSs []*appsv1.ReplicaSet) int64

MaxRevision finds the highest revision in the replica sets

func MaxSurge

func MaxSurge(rollout *v1alpha1.Rollout) int32

MaxSurge 最大(相比Rolling预期副本数)多出来的副本数

func MaxUnavailable

func MaxUnavailable(rollout *v1alpha1.Rollout) int32

MaxUnavailable 最大不可用副本数

func NeedsRestart

func NeedsRestart(rollout *v1alpha1.Rollout) bool

func NewRSNewReplicas

func NewRSNewReplicas(rollout *v1alpha1.Rollout, allRSs []*appsv1.ReplicaSet, newRS *appsv1.ReplicaSet) (int32, error)

func ParseExistingPodMetadata

func ParseExistingPodMetadata(rs *appsv1.ReplicaSet) *v1alpha1.PodTemplateMetadata

ParseExistingPodMetadata returns the existing podMetadata which was injected to the ReplicaSet based on examination of rollout.argoproj.io/ephemeral-metadata annotation on the ReplicaSet. Returns nil if there was no metadata, or the metadata was not parseable.

func PodTemplateEqualIgnoreHash

func PodTemplateEqualIgnoreHash(live, desired *corev1.PodTemplateSpec) bool

PodTemplateEqualIgnoreHash 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

NOTE: This is a modified version of deploymentutil.EqualIgnoreHash, but modified to perform defaulting on the desired spec. This is so that defaulted fields by the replicaset controller factor into the comparison. The reason this is necessary, is because unlike the deployment controller, the rollout controller does not benefit/operate on a completely defaulted rollout object.

func PodTemplateOrStepsChanged

func PodTemplateOrStepsChanged(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet) bool

PodTemplateOrStepsChanged detects if there is a change in either the pod template, or canary steps

func RemoveInjectedAntiAffinityRule

func RemoveInjectedAntiAffinityRule(affinity *corev1.Affinity, rollout v1alpha1.Rollout) *corev1.Affinity

func ResetCurrentStepIndex

func ResetCurrentStepIndex(rollout *v1alpha1.Rollout) *int32

ResetCurrentStepIndex resets the index back to zero unless there are no steps

func Revision

func Revision(obj runtime.Object) (int64, error)

Revision returns the revision number of the input object.

func SyncEphemeralPodMetadata

func SyncEphemeralPodMetadata(metadata *metav1.ObjectMeta, existingPodMetadata, desiredPodMetadata *v1alpha1.PodTemplateMetadata) (*metav1.ObjectMeta, bool)

SyncEphemeralPodMetadata will inject the desired pod metadata to the ObjectMeta as well as remove previously injected pod metadata which is no longer desired. This function is careful to only modify metadata that we injected previously, and not affect other metadata which might be controlled by other controllers (e.g. istio pod sidecar injector)

func SyncReplicaSetEphemeralPodMetadata

func SyncReplicaSetEphemeralPodMetadata(rs *appsv1.ReplicaSet, podMetadata *v1alpha1.PodTemplateMetadata) (*appsv1.ReplicaSet, bool)

SyncReplicaSetEphemeralPodMetadata injects the desired pod metadata to the ReplicaSet, and removes previously injected metadata (based on the rollout.argoproj.io/ephemeral-metadata annotation) if it is no longer desired. A podMetadata value of nil indicates all ephemeral metadata should be removed completely.

func UseSetCanaryScale

func UseSetCanaryScale(rollout *v1alpha1.Rollout) *v1alpha1.SetCanaryScale

Types

type ReplicaSetsByRevisionNumber

type ReplicaSetsByRevisionNumber []*appsv1.ReplicaSet

ReplicaSetsByRevisionNumber sorts a list of ReplicaSet by revision timestamp, using their creation timestamp as a tie breaker.

func (ReplicaSetsByRevisionNumber) Len

func (ReplicaSetsByRevisionNumber) Less

func (o ReplicaSetsByRevisionNumber) Less(i, j int) bool

func (ReplicaSetsByRevisionNumber) Swap

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

Jump to

Keyboard shortcuts

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