Skip to content

Commit 531893b

Browse files
authored
Merge pull request #1110 from Moscagus/canary-replicas
Use the primary replicas when scaling up the canary (no hpa)
2 parents e6bb47f + f7fd6cc commit 531893b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/canary/deployment_controller.go

+11
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ func (c *DeploymentController) ScaleFromZero(cd *flaggerv1.Canary) error {
208208
replicas := int32p(1)
209209
if dep.Spec.Replicas != nil && *dep.Spec.Replicas > 0 {
210210
replicas = dep.Spec.Replicas
211+
} else if cd.Spec.AutoscalerRef == nil {
212+
// If HPA isn't set and replicas are not specified, it uses the primary replicas when scaling up the canary
213+
primaryName := fmt.Sprintf("%s-primary", targetName)
214+
primary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{})
215+
if err != nil {
216+
return fmt.Errorf("deployment %s.%s get query error: %w", primaryName, cd.Namespace, err)
217+
}
218+
219+
if primary.Spec.Replicas != nil && *primary.Spec.Replicas > 0 {
220+
replicas = primary.Spec.Replicas
221+
}
211222
}
212223
depCopy := dep.DeepCopy()
213224
depCopy.Spec.Replicas = replicas

0 commit comments

Comments
 (0)