Skip to content

Commit 980a56d

Browse files
khhiranialexmt
authored andcommitted
fix: Nginx ingressClassName passed to canary ingress (argoproj#1448)
* fix: nginx ingressClassName passed to canary ingress Signed-off-by: khhirani <[email protected]>
1 parent 58994c9 commit 980a56d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

rollout/trafficrouting/nginx/nginx.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ func (r *Reconciler) canaryIngress(stableIngress *extensionsv1beta1.Ingress, nam
7272
},
7373
}
7474

75+
// Preserve ingressClassName from stable ingress
76+
if stableIngress.Spec.IngressClassName != nil {
77+
desiredCanaryIngress.Spec.IngressClassName = stableIngress.Spec.IngressClassName
78+
}
79+
7580
// Must preserve ingress.class on canary ingress, no other annotations matter
7681
// See: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#canary
7782
if val, ok := stableIngress.Annotations["kubernetes.io/ingress.class"]; ok {

rollout/trafficrouting/nginx/nginx_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55
"testing"
66

7+
"k8s.io/utils/pointer"
8+
79
"github.com/pkg/errors"
810
"github.com/stretchr/testify/assert"
911
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
@@ -94,13 +96,16 @@ func TestCanaryIngressCreate(t *testing.T) {
9496
},
9597
}
9698
stableIngress := ingress("stable-ingress", 80, "stable-service")
99+
stableIngress.Spec.IngressClassName = pointer.StringPtr("nginx-ext")
97100

98101
desiredCanaryIngress, err := r.canaryIngress(stableIngress, ingressutil.GetCanaryIngressName(r.cfg.Rollout), 10)
99102
assert.Nil(t, err, "No error returned when calling canaryIngress")
100103

101104
checkBackendService(t, desiredCanaryIngress, "canary-service")
102105
assert.Equal(t, "true", desiredCanaryIngress.Annotations["nginx.ingress.kubernetes.io/canary"], "canary annotation set to true")
103106
assert.Equal(t, "10", desiredCanaryIngress.Annotations["nginx.ingress.kubernetes.io/canary-weight"], "canary-weight annotation set to expected value")
107+
assert.NotNil(t, desiredCanaryIngress.Spec.IngressClassName)
108+
assert.Equal(t, "nginx-ext", *desiredCanaryIngress.Spec.IngressClassName)
104109
}
105110

106111
func TestCanaryIngressPatchWeight(t *testing.T) {

0 commit comments

Comments
 (0)