Documentation ¶
Index ¶
- func AtDesiredReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, ...) bool
- func BeforeStartingStep(rollout *v1alpha1.Rollout) bool
- func CalculateReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, ...) (int32, int32)
- func CheckPodSpecChange(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet) bool
- func CheckStableRSExists(newRS, stableRS *appsv1.ReplicaSet) bool
- func DesiredReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet) (int32, int32)
- 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 GetActualReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetAvailableReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetCurrentCanaryStep(rollout *v1alpha1.Rollout) (*v1alpha1.CanaryStep, *int32)
- func GetCurrentExperimentStep(r *v1alpha1.Rollout) *v1alpha1.RolloutExperimentStep
- func GetCurrentSetWeight(rollout *v1alpha1.Rollout) int32
- func GetOlderRSs(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, ...) []*appsv1.ReplicaSet
- func GetPodTemplateHash(rs *appsv1.ReplicaSet) string
- func GetReadyReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetReplicaSetByTemplateHash(allRS []*appsv1.ReplicaSet, podTemplateHash string) (*appsv1.ReplicaSet, []*appsv1.ReplicaSet)
- func GetReplicasForScaleDown(rs *appsv1.ReplicaSet) int32
- func GetStableRS(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, ...) *appsv1.ReplicaSet
- func MaxRevision(allRSs []*appsv1.ReplicaSet) int64
- func MaxSurge(rollout *v1alpha1.Rollout) int32
- func MaxUnavailable(rollout *v1alpha1.Rollout) int32
- func NewRSNewReplicas(rollout *v1alpha1.Rollout, allRSs []*appsv1.ReplicaSet, ...) (int32, error)
- 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 ResetCurrentStepIndex(rollout *v1alpha1.Rollout) *int32
- func Revision(obj runtime.Object) (int64, error)
- type ReplicaSetsByRevisionNumber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtDesiredReplicaCountsForCanary ¶ added in v0.2.0
func AtDesiredReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, olderRSs []*appsv1.ReplicaSet) bool
AtDesiredReplicaCountsForCanary indicates if the rollout is at the desired state for the current step
func BeforeStartingStep ¶ added in v0.7.0
BeforeStartingStep checks if canary rollout is at the starting step
func CalculateReplicaCountsForCanary ¶ added in v0.2.0
func CalculateReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, stableRS *appsv1.ReplicaSet, oldRSs []*appsv1.ReplicaSet) (int32, int32)
CalculateReplicaCountsForCanary calculates the number of replicas for the newRS and the stableRS. The function calculates the desired number of replicas for the new and stable RS using the following equations:
newRS Replica count = spec.Replica * (setweight / 100) stableRS Replica count = spec.Replica * ( (1 - setweight) / 100)
In both equations, the function rounds the desired replica count up if the math does not divide into whole numbers because the rollout guarantees at least one replica for both the stable and new RS when the setWeight is not 0 or 100. 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 precenence 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 TestCalculateReplicaCountsForCanary test in canary/canary_test.go
func CheckPodSpecChange ¶ added in v0.2.0
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 ¶ added in v0.2.0
func CheckStableRSExists(newRS, stableRS *appsv1.ReplicaSet) bool
CheckStableRSExists checks if the stableRS exists and is different than the newRS
func DesiredReplicaCountsForCanary ¶ added in v0.2.0
func DesiredReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet) (int32, int32)
DesiredReplicaCountsForCanary calculates the desired endstate replica count for the new and stable replicasets
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) []*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 GetCurrentCanaryStep ¶ added in v0.2.0
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 ¶ added in v0.6.0
func GetCurrentExperimentStep(r *v1alpha1.Rollout) *v1alpha1.RolloutExperimentStep
GetCurrentExperimentStep grabs the latest Experiment step
func GetCurrentSetWeight ¶ added in v0.2.0
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 GetOlderRSs ¶ added in v0.6.3
func GetOlderRSs(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, allRSs []*appsv1.ReplicaSet) []*appsv1.ReplicaSet
GetOlderRSs the function goes through a list of ReplicaSets and returns a list of RS that are not the new or stable RS
func GetPodTemplateHash ¶ added in v0.4.0
func GetPodTemplateHash(rs *appsv1.ReplicaSet) string
GetPodTemplateHash returns the rollouts-pod-template-hash value from a ReplicaSet's labels
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 ¶ added in v0.3.1
func GetReplicaSetByTemplateHash(allRS []*appsv1.ReplicaSet, podTemplateHash string) (*appsv1.ReplicaSet, []*appsv1.ReplicaSet)
GetReplicaSetByTemplateHash find the replicaset that matches the podTemplateHash
func GetReplicasForScaleDown ¶ added in v0.4.2
func GetReplicasForScaleDown(rs *appsv1.ReplicaSet) int32
GetReplicasForScaleDown returns the number of replicas to consider for scaling down.
func GetStableRS ¶ added in v0.2.0
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 MaxRevision ¶
func MaxRevision(allRSs []*appsv1.ReplicaSet) int64
MaxRevision finds the highest revision in the replica sets
func MaxSurge ¶ added in v0.2.0
MaxSurge returns the maximum surge pods a rolling deployment can take.
func MaxUnavailable ¶ added in v0.2.0
MaxUnavailable returns the maximum unavailable pods a rolling deployment can take.
func NewRSNewReplicas ¶
func NewRSNewReplicas(rollout *v1alpha1.Rollout, allRSs []*appsv1.ReplicaSet, newRS *appsv1.ReplicaSet) (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 PodTemplateEqualIgnoreHash ¶ added in v0.4.0
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 ¶ added in v0.4.0
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 ¶ added in v0.3.1
func ReadyForPause(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, allRSs []*appsv1.ReplicaSet) bool
func ResetCurrentStepIndex ¶ added in v0.2.0
ResetCurrentStepIndex resets the index back to zero unless there are no steps
Types ¶
type ReplicaSetsByRevisionNumber ¶ added in v0.5.0
type ReplicaSetsByRevisionNumber []*appsv1.ReplicaSet
ReplicaSetsByRevisionNumber sorts a list of ReplicaSet by revision timestamp, using their creation timestamp as a tie breaker.
func (ReplicaSetsByRevisionNumber) Len ¶ added in v0.5.0
func (o ReplicaSetsByRevisionNumber) Len() int
func (ReplicaSetsByRevisionNumber) Less ¶ added in v0.5.0
func (o ReplicaSetsByRevisionNumber) Less(i, j int) bool
func (ReplicaSetsByRevisionNumber) Swap ¶ added in v0.5.0
func (o ReplicaSetsByRevisionNumber) Swap(i, j int)