Documentation ¶
Index ¶
- Constants
- func AtDesiredReplicaCountsForCanary(ro *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, ...) bool
- func BeforeStartingStep(rollout *v1alpha1.Rollout) bool
- func CalculateReplicaCountsForBasicCanary(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, ...) (int32, int32)
- func CalculateReplicaCountsForTrafficRoutedCanary(rollout *v1alpha1.Rollout, weights *v1alpha1.TrafficWeights) (int32, int32)
- func CheckMinPodsPerReplicaSet(rollout *v1alpha1.Rollout, count int32) int32
- func CheckPodSpecChange(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet) bool
- func CheckStableRSExists(newRS, stableRS *appsv1.ReplicaSet) bool
- func CreateInjectedAntiAffinityRule(rollout v1alpha1.Rollout) corev1.PodAffinityTerm
- func FindActiveOrLatest(newRS *appsv1.ReplicaSet, oldRSs []*appsv1.ReplicaSet) *appsv1.ReplicaSet
- func FindNewReplicaSet(rollout *v1alpha1.Rollout, rsList []*appsv1.ReplicaSet) *appsv1.ReplicaSet
- func FindOldReplicaSets(rollout *v1alpha1.Rollout, rsList []*appsv1.ReplicaSet, ...) []*appsv1.ReplicaSet
- func GenerateReplicaSetAffinity(rollout v1alpha1.Rollout) *corev1.Affinity
- func GetActualReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetAvailableReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetCanaryReplicasOrWeight(rollout *v1alpha1.Rollout) (*int32, int32)
- func GetCurrentCanaryStep(rollout *v1alpha1.Rollout) (*v1alpha1.CanaryStep, *int32)
- func GetCurrentExperimentStep(r *v1alpha1.Rollout) *v1alpha1.RolloutExperimentStep
- func GetCurrentSetWeight(rollout *v1alpha1.Rollout) int32
- func GetOtherRSs(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, ...) []*appsv1.ReplicaSet
- func GetPodTemplateHash(rs *appsv1.ReplicaSet) string
- func GetPodsOwnedByReplicaSet(ctx context.Context, client kubernetes.Interface, rs *appsv1.ReplicaSet) ([]*corev1.Pod, error)
- func GetReadyReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetReplicaSetByTemplateHash(allRS []*appsv1.ReplicaSet, podTemplateHash string) (*appsv1.ReplicaSet, []*appsv1.ReplicaSet)
- func GetReplicaSetRevision(ro *v1alpha1.Rollout, rs *appsv1.ReplicaSet) int
- func GetReplicasForScaleDown(rs *appsv1.ReplicaSet, ignoreAvailability bool) int32
- func GetRolloutAffinity(rollout v1alpha1.Rollout) *v1alpha1.AntiAffinity
- func GetStableRS(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, ...) *appsv1.ReplicaSet
- func GetTimeRemainingBeforeScaleDownDeadline(rs *appsv1.ReplicaSet) (*time.Duration, error)
- func HasInjectedAntiAffinityRule(affinity *corev1.Affinity, rollout v1alpha1.Rollout) (int, *corev1.PodAffinityTerm)
- func HasScaleDownDeadline(rs *appsv1.ReplicaSet) bool
- func IfInjectedAntiAffinityRuleNeedsUpdate(affinity *corev1.Affinity, rollout v1alpha1.Rollout) bool
- func IsActive(rs *appsv1.ReplicaSet) bool
- func IsReplicaSetAvailable(rs *appsv1.ReplicaSet) bool
- func IsReplicaSetPartiallyAvailable(rs *appsv1.ReplicaSet) bool
- func MaxRevision(allRSs []*appsv1.ReplicaSet) int64
- func MaxSurge(rollout *v1alpha1.Rollout) int32
- func MaxUnavailable(rollout *v1alpha1.Rollout) int32
- func NeedsRestart(rollout *v1alpha1.Rollout) bool
- func NewRSNewReplicas(rollout *v1alpha1.Rollout, allRSs []*appsv1.ReplicaSet, ...) (int32, error)
- func ParseExistingPodMetadata(rs *appsv1.ReplicaSet) *v1alpha1.PodTemplateMetadata
- func PodTemplateEqualIgnoreHash(live, desired *corev1.PodTemplateSpec) bool
- func PodTemplateOrStepsChanged(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet) bool
- func ReadyForPause(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, ...) bool
- func RemoveInjectedAntiAffinityRule(affinity *corev1.Affinity, rollout v1alpha1.Rollout) *corev1.Affinity
- func ResetCurrentStepIndex(rollout *v1alpha1.Rollout) *int32
- func Revision(obj runtime.Object) (int64, error)
- func SyncEphemeralPodMetadata(metadata *metav1.ObjectMeta, ...) (*metav1.ObjectMeta, bool)
- func SyncReplicaSetEphemeralPodMetadata(rs *appsv1.ReplicaSet, podMetadata *v1alpha1.PodTemplateMetadata) (*appsv1.ReplicaSet, bool)
- func UseSetCanaryScale(rollout *v1alpha1.Rollout) *v1alpha1.SetCanaryScale
- type ReplicaSetsByRevisionNumber
Constants ¶
const ( // EphemeralMetadataAnnotation denotes pod metadata which is ephemerally injected to canary/stable pods EphemeralMetadataAnnotation = annotations.RolloutLabel + "/ephemeral-metadata" )
Variables ¶
This section is empty.
Functions ¶
func AtDesiredReplicaCountsForCanary ¶
func AtDesiredReplicaCountsForCanary(ro *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, olderRSs []*appsv1.ReplicaSet, weights *v1alpha1.TrafficWeights) bool
func BeforeStartingStep ¶
BeforeStartingStep checks if canary rollout is at the starting step
func CalculateReplicaCountsForBasicCanary ¶
func CalculateReplicaCountsForBasicCanary(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, stableRS *appsv1.ReplicaSet, oldRSs []*appsv1.ReplicaSet) (int32, int32)
CalculateReplicaCountsForBasicCanary calculates the number of replicas for the newRS and the stableRS when using the basic canary strategy. The function calculates the desired number of replicas for the new and stable RS using the following equations:
desired newRS Replica count = spec.Replica * (setweight / maxweight) desired stableRS Replica count = spec.Replica - newRS
The function for newRS finds the closest whole number of replicas based on the weight percentage and rounds up the desired replica count in case of a tie.
Then, the function finds the number of replicas it can scale up using the following equation:
scaleUpCount := (maxSurge + rollout.Spec.Replica) - sum of rollout's RSs spec.Replica
If the rollout has not reached its max number of replicas, it will scale up the RS whose desired replica count is greater than its current count to the desired number. The rollout will either scale the RS up as much as it can unless the rollout can reach the RS desired count. In order to give precedence to the stableRS, the function will scale up the stable RS to desired count before scaling up the new RS.
At this point, the function then finds the number of replicas it can scale down using the following equation:
scaleDownCount := count of all the available replicas - (spec.Replica - maxUnavailable)
If the rollout has not reached at the min available replicas count, it will scale down the RS whose desired replica count is less than its current count to the desired number. However before scaling any new or stable RS down, the function will scale down the replicas in the old RS list first. Afterwards if the rollout is not at the min available replica count, the function will check the newRS before the stableRS.
Examples: replicas 10 currentWeight 10 NewRS 0 stableRS 10 max unavailable 1, surge 1 - should return newRS 1 stableRS 9 replicas 10 currentWeight 30 NewRS 0 stableRS 10 max unavailable 0, surge 3 - should return newRS 3 stableRS 10 replicas 10 currentWeight 30 NewRS 0 stableRS 10 max unavailable 5, surge 0 - should return newRS 0 stableRS 7 replicas 10 currentWeight 5 NewRS 0 stableRS 10 max unavailable 1, surge 1 - should return newRS 1 stableRS 9 replicas 1 currentWeight 5 NewRS 0 stableRS 1 max unavailable 0, surge 1 - should return newRS 1 stableRS 1 replicas 1 currentWeight 95 NewRS 0 stableRS 1 max unavailable 0, surge 1 - should return newRS 1 stableRS 1 For more examples, check the CalculateReplicaCountsForBasicCanary test in canary/canary_test.go
func CalculateReplicaCountsForTrafficRoutedCanary ¶
func CalculateReplicaCountsForTrafficRoutedCanary(rollout *v1alpha1.Rollout, weights *v1alpha1.TrafficWeights) (int32, int32)
CalculateReplicaCountsForTrafficRoutedCanary calculates the canary and stable replica counts when using canary with traffic routing. If current traffic weights are supplied, we factor the those weights into the and return the higher of current traffic scale vs. desired traffic scale If MinPodsPerReplicaSet is defined and the number of replicas in either RS is not 0, then return at least MinPodsPerReplicaSet
func CheckMinPodsPerReplicaSet ¶
CheckMinPodsPerReplicaSet ensures that if the desired number of pods in a stable or canary ReplicaSet is not zero, then it is at least MinPodsPerReplicaSet for High Availability. Only applicable if using TrafficRouting
func CheckPodSpecChange ¶
func CheckPodSpecChange(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet) bool
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 returns the new RS this given rollout targets from the given list. Returns nil if the ReplicaSet does not exist in the list.
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.
func GetActualReplicaCountForReplicaSets ¶
func GetActualReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
GetActualReplicaCountForReplicaSets returns the sum of actual replicas of the given replica sets.
func GetAvailableReplicaCountForReplicaSets ¶
func GetAvailableReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
GetAvailableReplicaCountForReplicaSets returns the number of available pods corresponding to the given replica sets.
func GetCanaryReplicasOrWeight ¶
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 GetCurrentExperimentStep ¶
func GetCurrentExperimentStep(r *v1alpha1.Rollout) *v1alpha1.RolloutExperimentStep
GetCurrentExperimentStep grabs the latest Experiment step
func GetCurrentSetWeight ¶
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 GetReplicaSetByTemplateHash ¶
func GetReplicaSetByTemplateHash(allRS []*appsv1.ReplicaSet, podTemplateHash string) (*appsv1.ReplicaSet, []*appsv1.ReplicaSet)
GetReplicaSetByTemplateHash find the replicaset that matches the podTemplateHash
func GetReplicaSetRevision ¶
func GetReplicaSetRevision(ro *v1alpha1.Rollout, rs *appsv1.ReplicaSet) int
func GetReplicasForScaleDown ¶
func GetReplicasForScaleDown(rs *appsv1.ReplicaSet, ignoreAvailability bool) int32
GetReplicasForScaleDown returns the total number of replicas to consider for scaling down the given ReplicaSet. ignoreAvailability indicates if we are allowed to ignore availability of pods during the calculation, in which case we return just the desired replicas. The purpose of ignoring availability is to handle the case when the ReplicaSet which we are considering for scaledown might be scaled up, but its pods may be unavailable (e.g. because of a CrashloopBackoff). In this case we need to return the spec.Replicas so that the controller will still consider scaling down this ReplicaSet. Without this, a rollout could become stuck not scaling down the stable, in order to make room for more canaries.
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 HasScaleDownDeadline ¶
func HasScaleDownDeadline(rs *appsv1.ReplicaSet) bool
HasScaleDownDeadline returns whether or not the given ReplicaSet is annotated with a scale-down delay
func IsActive ¶
func IsActive(rs *appsv1.ReplicaSet) bool
IsActive returns if replica set is active (has, or at least ought to have pods).
func IsReplicaSetAvailable ¶
func IsReplicaSetAvailable(rs *appsv1.ReplicaSet) bool
IsReplicaSetAvailable returns if a ReplicaSet is scaled up and its ready count is >= desired count
func IsReplicaSetPartiallyAvailable ¶
func IsReplicaSetPartiallyAvailable(rs *appsv1.ReplicaSet) bool
IsReplicaSetPartiallyAvailable returns if a ReplicaSet is scaled up and has at least 1 pod available
func MaxRevision ¶
func MaxRevision(allRSs []*appsv1.ReplicaSet) int64
MaxRevision finds the highest revision in the replica sets
func MaxUnavailable ¶
MaxUnavailable returns the maximum unavailable pods a rolling deployment can take.
func NeedsRestart ¶
func NewRSNewReplicas ¶
func NewRSNewReplicas(rollout *v1alpha1.Rollout, allRSs []*appsv1.ReplicaSet, newRS *appsv1.ReplicaSet, weights *v1alpha1.TrafficWeights) (int32, error)
NewRSNewReplicas calculates the number of replicas a Rollout's new RS should have. When one of the followings is true, we're rolling out the deployment; otherwise, we're scaling it. 1) The new RS is saturated: newRS's replicas == deployment's replicas 2) Max number of pods allowed is reached: deployment's replicas + maxSurge == all RSs' replicas
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:
- 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)
- 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 ReadyForPause ¶
func ReadyForPause(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, allRSs []*appsv1.ReplicaSet) bool
func ResetCurrentStepIndex ¶
ResetCurrentStepIndex resets the index back to zero unless there are no steps
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
UseSetCanaryScale will return a SetCanaryScale if specified and should be used, returns nil otherwise. TrafficRouting is required to be set for SetCanaryScale to be applicable. If MatchTrafficWeight is set after a previous SetCanaryScale step, it will likewise be ignored.
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 (o ReplicaSetsByRevisionNumber) Len() int
func (ReplicaSetsByRevisionNumber) Less ¶
func (o ReplicaSetsByRevisionNumber) Less(i, j int) bool
func (ReplicaSetsByRevisionNumber) Swap ¶
func (o ReplicaSetsByRevisionNumber) Swap(i, j int)