diff --git a/pkg/canary/daemonset_controller.go b/pkg/canary/daemonset_controller.go index 44833388..a8d74de8 100644 --- a/pkg/canary/daemonset_controller.go +++ b/pkg/canary/daemonset_controller.go @@ -215,6 +215,7 @@ func (c *DaemonSetController) createPrimaryDaemonSet(cd *flaggerv1.Canary) error } label, labelValue, err := c.getSelectorLabel(canaryDae) + primaryLabelValue := fmt.Sprintf("%s-primary", labelValue); if err != nil { return fmt.Errorf("getSelectorLabel failed: %w", err) } @@ -240,7 +241,7 @@ func (c *DaemonSetController) createPrimaryDaemonSet(cd *flaggerv1.Canary) error Name: primaryName, Namespace: cd.Namespace, Labels: map[string]string{ - label: labelValue, + label: primaryLabelValue, }, OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(cd, schema.GroupVersionKind{ @@ -256,12 +257,12 @@ func (c *DaemonSetController) createPrimaryDaemonSet(cd *flaggerv1.Canary) error UpdateStrategy: canaryDae.Spec.UpdateStrategy, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ - label: labelValue, + label: primaryLabelValue, }, }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: makePrimaryLabels(canaryDae.Spec.Template.Labels, labelValue, label), + Labels: makePrimaryLabels(canaryDae.Spec.Template.Labels, primaryLabelValue, label), Annotations: annotations, }, // update spec with the primary secrets and config maps diff --git a/pkg/canary/deployment_controller.go b/pkg/canary/deployment_controller.go index 72584d9d..b57a8d09 100644 --- a/pkg/canary/deployment_controller.go +++ b/pkg/canary/deployment_controller.go @@ -211,6 +211,7 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary) err } label, labelValue, err := c.getSelectorLabel(canaryDep) + primaryLabelValue := fmt.Sprintf("%s-primary", labelValue); if err != nil { return fmt.Errorf("getSelectorLabel failed: %w", err) } @@ -241,7 +242,7 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary) err Name: primaryName, Namespace: cd.Namespace, Labels: map[string]string{ - label: labelValue, + label: primaryLabelValue, }, OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(cd, schema.GroupVersionKind{ @@ -259,12 +260,12 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary) err Strategy: canaryDep.Spec.Strategy, Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ - label: labelValue, + label: primaryLabelValue, }, }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: makePrimaryLabels(canaryDep.Spec.Template.Labels, primaryName, label), + Labels: makePrimaryLabels(canaryDep.Spec.Template.Labels, primaryLabelValue, label), Annotations: annotations, }, // update spec with the primary secrets and config maps