Documentation ¶
Index ¶
- func AtDesiredReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS, stableRS *appsv1.ReplicaSet, ...) bool
- func CalculateReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, ...) (int32, int32)
- func CheckPodSpecChange(rollout *v1alpha1.Rollout) bool
- func CheckStableRSExists(newRS, stableRS *appsv1.ReplicaSet) bool
- func CheckStepHashChange(rollout *v1alpha1.Rollout) 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 GetCurrentSetWeight(rollout *v1alpha1.Rollout) int32
- func GetReadyReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetReplicaCountForReplicaSets(replicaSets []*appsv1.ReplicaSet) int32
- func GetStableRS(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, ...) (*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 ResetCurrentStepIndex(rollout *v1alpha1.Rollout) *int32
- func Revision(obj runtime.Object) (int64, error)
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 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
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 CheckStepHashChange ¶ added in v0.2.0
CheckStepHashChange indicates if the rollout's step for the strategy have changed. This causes the rollout to reset the currentStepIndex to zero. If there is no previous pod spec to compare to the function defaults to false
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.
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 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 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 GetStableRS ¶ added in v0.2.0
func GetStableRS(rollout *v1alpha1.Rollout, newRS *appsv1.ReplicaSet, rslist []*appsv1.ReplicaSet) (*appsv1.ReplicaSet, []*appsv1.ReplicaSet)
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 ResetCurrentStepIndex ¶ added in v0.2.0
ResetCurrentStepIndex resets the index back to zero unless there are no steps
Types ¶
This section is empty.