diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a50e7b16..4b3450e3 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -28,6 +28,9 @@ jobs: uses: actions/checkout@v2 - name: Setup Kubernetes uses: engineerd/setup-kind@v0.5.0 + with: + version: "v0.11.0" + image: kindest/node:v1.21.1@sha256:fae9a58f17f18f06aeac9772ca8b5ac680ebbed985e266f711d936e91d113bad - name: Build container image run: | docker build -t test/flagger:latest . diff --git a/docs/gitbook/tutorials/nginx-progressive-delivery.md b/docs/gitbook/tutorials/nginx-progressive-delivery.md index 2fce78c7..56e69d49 100644 --- a/docs/gitbook/tutorials/nginx-progressive-delivery.md +++ b/docs/gitbook/tutorials/nginx-progressive-delivery.md @@ -6,7 +6,7 @@ This guide shows you how to use the NGINX ingress controller and Flagger to auto ## Prerequisites -Flagger requires a Kubernetes cluster **v1.16** or newer and NGINX ingress **v0.41** or newer. +Flagger requires a Kubernetes cluster **v1.19** or newer and NGINX ingress **v0.46** or newer. Install the NGINX ingress controller with Helm v3: @@ -59,7 +59,7 @@ helm upgrade -i flagger-loadtester flagger/loadtester \ Create an ingress definition (replace `app.example.com` with your own domain): ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: podinfo @@ -70,12 +70,16 @@ metadata: kubernetes.io/ingress.class: "nginx" spec: rules: - - host: app.example.com + - host: "app.example.com" http: paths: - - backend: - serviceName: podinfo - servicePort: 80 + - pathType: Prefix + path: "/" + backend: + service: + name: podinfo + port: + number: 80 ``` Save the above resource as podinfo-ingress.yaml and then apply it: @@ -101,7 +105,7 @@ spec: name: podinfo # ingress reference ingressRef: - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress name: podinfo # HPA reference (optional) diff --git a/docs/gitbook/tutorials/skipper-progressive-delivery.md b/docs/gitbook/tutorials/skipper-progressive-delivery.md index 5963578b..dc1a9c99 100644 --- a/docs/gitbook/tutorials/skipper-progressive-delivery.md +++ b/docs/gitbook/tutorials/skipper-progressive-delivery.md @@ -6,7 +6,7 @@ This guide shows you how to use the [Skipper ingress controller](https://opensou ## Prerequisites -Flagger requires a Kubernetes cluster **v1.16** or newer and Skipper ingress **0.11.40** or newer. +Flagger requires a Kubernetes cluster **v1.19** or newer and Skipper ingress **v0.13** or newer. Install Skipper ingress-controller using [upstream definition](https://opensource.zalando.com/skipper/kubernetes/ingress-controller/#install-skipper-as-ingress-controller). @@ -36,7 +36,9 @@ kustomize build https://github.com/fluxcd/flagger/kustomize/kubernetes | kubectl ## Bootstrap -Flagger takes a Kubernetes deployment and optionally a horizontal pod autoscaler \(HPA\), then creates a series of objects \(Kubernetes deployments, ClusterIP services and canary ingress\). These objects expose the application outside the cluster and drive the canary analysis and promotion. +Flagger takes a Kubernetes deployment and optionally a horizontal pod autoscaler (HPA), +then creates a series of objects (Kubernetes deployments, ClusterIP services and canary ingress). +These objects expose the application outside the cluster and drive the canary analysis and promotion. Create a test namespace: @@ -60,7 +62,7 @@ helm upgrade -i flagger-loadtester flagger/loadtester \ Create an ingress definition \(replace `app.example.com` with your own domain\): ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: podinfo @@ -71,12 +73,16 @@ metadata: kubernetes.io/ingress.class: "skipper" spec: rules: - - host: app.example.com + - host: "app.example.com" http: paths: - - backend: - serviceName: podinfo - servicePort: 80 + - pathType: Prefix + path: "/" + backend: + service: + name: podinfo + port: + number: 80 ``` Save the above resource as podinfo-ingress.yaml and then apply it: @@ -85,7 +91,7 @@ Save the above resource as podinfo-ingress.yaml and then apply it: kubectl apply -f ./podinfo-ingress.yaml ``` -Create a canary custom resource \(replace `app.example.com` with your own domain\): +Create a canary custom resource (replace `app.example.com` with your own domain): ```yaml apiVersion: flagger.app/v1beta1 @@ -102,7 +108,7 @@ spec: name: podinfo # ingress reference ingressRef: - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress name: podinfo # HPA reference (optional) @@ -190,7 +196,9 @@ ingress.networking.k8s.io/podinfo-canary ## Automated canary promotion -Flagger implements a control loop that gradually shifts traffic to the canary while measuring key performance indicators like HTTP requests success rate, requests average duration and pod health. Based on analysis of the KPIs a canary is promoted or aborted, and the analysis result is published to Slack or MS Teams. +Flagger implements a control loop that gradually shifts traffic to the canary while measuring +key performance indicators like HTTP requests success rate, requests average duration and pod health. +Based on analysis of the KPIs a canary is promoted or aborted, and the analysis result is published to Slack or MS Teams. ![Flagger Canary Stages](https://raw.githubusercontent.com/fluxcd/flagger/main/docs/diagrams/flagger-canary-steps.png) @@ -271,7 +279,8 @@ Generate latency: watch -n 1 curl http://app.example.com/delay/1 ``` -When the number of failed checks reaches the canary analysis threshold, the traffic is routed back to the primary, the canary is scaled to zero and the rollout is marked as failed. +When the number of failed checks reaches the canary analysis threshold, the traffic is routed back to the primary, +the canary is scaled to zero and the rollout is marked as failed. ```text kubectl -n flagger-system logs deploy/flagger -f | jq .msg @@ -333,7 +342,8 @@ Edit the canary analysis and add the latency check: interval: 1m ``` -The threshold is set to 500ms so if the average request duration in the last minute goes over half a second then the analysis will fail and the canary will not be promoted. +The threshold is set to 500ms so if the average request duration in the last minute goes over half a second +then the analysis will fail and the canary will not be promoted. Trigger a canary deployment by updating the container image: @@ -367,4 +377,3 @@ Canary failed! Scaling down podinfo.test ``` If you have alerting configured, Flagger will send a notification with the reason why the canary failed. - diff --git a/pkg/router/ingress.go b/pkg/router/ingress.go index c6f4047a..01fd58a3 100644 --- a/pkg/router/ingress.go +++ b/pkg/router/ingress.go @@ -24,7 +24,7 @@ import ( "github.com/google/go-cmp/cmp" "go.uber.org/zap" - "k8s.io/api/networking/v1beta1" + netv1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -48,7 +48,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { canaryName := fmt.Sprintf("%s-canary", apexName) canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name) - ingress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canary.Spec.IngressRef.Name, metav1.GetOptions{}) + ingress, err := i.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get(context.TODO(), canary.Spec.IngressRef.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s get query error: %w", canary.Spec.IngressRef.Name, canary.Namespace, err) } @@ -59,8 +59,8 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { backendExists := false for k, v := range ingressClone.Spec.Rules { for x, y := range v.HTTP.Paths { - if y.Backend.ServiceName == apexName { - ingressClone.Spec.Rules[k].HTTP.Paths[x].Backend.ServiceName = canaryName + if y.Backend.Service != nil && y.Backend.Service.Name == apexName { + ingressClone.Spec.Rules[k].HTTP.Paths[x].Backend.Service.Name = canaryName backendExists = true } } @@ -70,10 +70,10 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { return fmt.Errorf("backend %s not found in ingress %s", apexName, canary.Spec.IngressRef.Name) } - canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := i.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if errors.IsNotFound(err) { - ing := &v1beta1.Ingress{ + ing := &netv1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: canaryIngressName, Namespace: canary.Namespace, @@ -90,7 +90,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { Spec: ingressClone.Spec, } - _, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Create(context.TODO(), ing, metav1.CreateOptions{}) + _, err := i.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Create(context.TODO(), ing, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s create error: %w", ing.Name, ing.Namespace, err) } @@ -106,7 +106,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { iClone := canaryIngress.DeepCopy() iClone.Spec = ingressClone.Spec - _, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(context.TODO(), iClone, metav1.UpdateOptions{}) + _, err := i.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Update(context.TODO(), iClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s update error: %w", canaryIngressName, iClone.Namespace, err) } @@ -125,7 +125,7 @@ func (i *IngressRouter) GetRoutes(canary *flaggerv1.Canary) ( err error, ) { canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name) - canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := i.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err) return @@ -166,7 +166,7 @@ func (i *IngressRouter) SetRoutes( _ bool, ) error { canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name) - canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := i.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err) } @@ -201,7 +201,7 @@ func (i *IngressRouter) SetRoutes( iClone.Annotations = i.makeAnnotations(iClone.Annotations) } - _, err = i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(context.TODO(), iClone, metav1.UpdateOptions{}) + _, err = i.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Update(context.TODO(), iClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s update error %v", iClone.Name, iClone.Namespace, err) } diff --git a/pkg/router/ingress_test.go b/pkg/router/ingress_test.go index f327406a..53c2df50 100644 --- a/pkg/router/ingress_test.go +++ b/pkg/router/ingress_test.go @@ -45,7 +45,7 @@ func TestIngressRouter_Reconcile(t *testing.T) { canaryWeightAn := "custom.ingress.kubernetes.io/canary-weight" canaryName := fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) + inCanary, err := router.kubeClient.NetworkingV1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test initialisation @@ -78,7 +78,7 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) { canaryWeightAn := "prefix1.nginx.ingress.kubernetes.io/canary-weight" canaryName := fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) + inCanary, err := router.kubeClient.NetworkingV1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test rollout @@ -92,7 +92,7 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) { err = router.SetRoutes(mocks.ingressCanary, p, c, m) require.NoError(t, err) - inCanary, err = router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) + inCanary, err = router.kubeClient.NetworkingV1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test promotion @@ -175,7 +175,7 @@ func TestIngressRouter_ABTest(t *testing.T) { canaryAn := router.GetAnnotationWithPrefix("canary") canaryName := fmt.Sprintf("%s-canary", table.makeCanary().Spec.IngressRef.Name) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) + inCanary, err := router.kubeClient.NetworkingV1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test initialisation diff --git a/pkg/router/router_test.go b/pkg/router/router_test.go index 9ecbd93d..ee3cb24f 100644 --- a/pkg/router/router_test.go +++ b/pkg/router/router_test.go @@ -20,7 +20,7 @@ import ( "go.uber.org/zap" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/api/networking/v1beta1" + netv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes" @@ -415,7 +415,7 @@ func newTestCanaryIngress() *flaggerv1.Canary { }, IngressRef: &flaggerv1.CrossNamespaceObjectReference{ Name: "podinfo", - APIVersion: "extensions/v1beta1", + APIVersion: "networking.k8s.io/v1", Kind: "Ingress", }, Service: flaggerv1.CanaryService{ @@ -437,9 +437,9 @@ func newTestCanaryIngress() *flaggerv1.Canary { return cd } -func newTestIngress() *v1beta1.Ingress { - return &v1beta1.Ingress{ - TypeMeta: metav1.TypeMeta{APIVersion: v1beta1.SchemeGroupVersion.String()}, +func newTestIngress() *netv1.Ingress { + return &netv1.Ingress{ + TypeMeta: metav1.TypeMeta{APIVersion: netv1.SchemeGroupVersion.String()}, ObjectMeta: metav1.ObjectMeta{ Namespace: "default", Name: "podinfo", @@ -447,18 +447,22 @@ func newTestIngress() *v1beta1.Ingress { "kubernetes.io/ingress.class": "nginx", }, }, - Spec: v1beta1.IngressSpec{ - Rules: []v1beta1.IngressRule{ + Spec: netv1.IngressSpec{ + Rules: []netv1.IngressRule{ { Host: "app.example.com", - IngressRuleValue: v1beta1.IngressRuleValue{ - HTTP: &v1beta1.HTTPIngressRuleValue{ - Paths: []v1beta1.HTTPIngressPath{ + IngressRuleValue: netv1.IngressRuleValue{ + HTTP: &netv1.HTTPIngressRuleValue{ + Paths: []netv1.HTTPIngressPath{ { Path: "/", - Backend: v1beta1.IngressBackend{ - ServiceName: "podinfo", - ServicePort: intstr.FromInt(9898), + Backend: netv1.IngressBackend{ + Service: &netv1.IngressServiceBackend{ + Name: "podinfo", + Port: netv1.ServiceBackendPort{ + Number: 9898, + }, + }, }, }, }, diff --git a/pkg/router/skipper.go b/pkg/router/skipper.go index a33208ab..76285dbe 100644 --- a/pkg/router/skipper.go +++ b/pkg/router/skipper.go @@ -69,7 +69,7 @@ func (skp *SkipperRouter) Reconcile(canary *flaggerv1.Canary) error { apexIngressName, canaryIngressName := skp.getIngressNames(canary.Spec.IngressRef.Name) // retrieving apex ingress - apexIngress, err := skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get( + apexIngress, err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get( context.TODO(), apexIngressName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("apexIngress %s.%s get query error: %w", apexIngressName, canary.Namespace, err) @@ -81,12 +81,12 @@ func (skp *SkipperRouter) Reconcile(canary *flaggerv1.Canary) error { rule := &iClone.Spec.Rules[x] // ref not value for y := range rule.HTTP.Paths { path := &rule.HTTP.Paths[y] // ref not value - if path.Backend.ServiceName == apexSvcName { + if path.Backend.Service != nil && path.Backend.Service.Name == apexSvcName { // flipping to primary service - path.Backend.ServiceName = primarySvcName + path.Backend.Service.Name = primarySvcName // adding second canary service canaryBackend := path.DeepCopy() - canaryBackend.Backend.ServiceName = canarySvcName + canaryBackend.Backend.Service.Name = canarySvcName rule.HTTP.Paths = append(rule.HTTP.Paths, *canaryBackend) } } @@ -107,14 +107,14 @@ func (skp *SkipperRouter) Reconcile(canary *flaggerv1.Canary) error { } // search for existence - canaryIngress, err := skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get( + canaryIngress, err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get( context.TODO(), canaryIngressName, metav1.GetOptions{}) // new ingress if errors.IsNotFound(err) { // Let K8s set this. Otherwise K8s API complains with "resourceVersion should not be set on objects to be created" iClone.ObjectMeta.ResourceVersion = "" - _, err := skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Create(context.TODO(), iClone, metav1.CreateOptions{}) + _, err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Create(context.TODO(), iClone, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s create error: %w", iClone.Name, iClone.Namespace, err) } @@ -131,7 +131,7 @@ func (skp *SkipperRouter) Reconcile(canary *flaggerv1.Canary) error { ingressClone.Spec = iClone.Spec ingressClone.Annotations = iClone.Annotations - _, err := skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(context.TODO(), ingressClone, metav1.UpdateOptions{}) + _, err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Update(context.TODO(), ingressClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s update error: %w", canaryIngressName, ingressClone.Namespace, err) } @@ -145,7 +145,7 @@ func (skp *SkipperRouter) GetRoutes(canary *flaggerv1.Canary) (primaryWeight, ca _, primarySvcName, canarySvcName := canary.GetServiceNames() _, canaryIngressName := skp.getIngressNames(canary.Spec.IngressRef.Name) - canaryIngress, err := skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err) return @@ -176,7 +176,7 @@ func (skp *SkipperRouter) GetRoutes(canary *flaggerv1.Canary) (primaryWeight, ca func (skp *SkipperRouter) SetRoutes(canary *flaggerv1.Canary, primaryWeight, canaryWeight int, _ bool) (err error) { _, primarySvcName, canarySvcName := canary.GetServiceNames() _, canaryIngressName := skp.getIngressNames(canary.Spec.IngressRef.Name) - canaryIngress, err := skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err) } @@ -197,7 +197,7 @@ func (skp *SkipperRouter) SetRoutes(canary *flaggerv1.Canary, primaryWeight, can iClone.Annotations[skipperpredicateAnnotationKey] = insertPredicate(iClone.Annotations[skipperpredicateAnnotationKey], canaryRouteDisable) } - _, err = skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update( + _, err = skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Update( context.TODO(), iClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s update error %w", iClone.Name, iClone.Namespace, err) @@ -214,7 +214,7 @@ func (skp *SkipperRouter) Finalize(canary *flaggerv1.Canary) error { skp.logger.With("deleteCanaryIngress", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)). Debugf("Deleting Canary Ingress: %s", canaryIngressName) - err := skp.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Delete( + err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Delete( context.TODO(), canaryIngressName, metav1.DeleteOptions{GracePeriodSeconds: &gracePeriodSeconds}) if err != nil { return fmt.Errorf("ingress %s.%s unable to remove canary ingress: %w", canaryIngressName, canary.Namespace, err) diff --git a/pkg/router/skipper_test.go b/pkg/router/skipper_test.go index 3b96f0bc..2d95a77d 100644 --- a/pkg/router/skipper_test.go +++ b/pkg/router/skipper_test.go @@ -43,7 +43,7 @@ func TestSkipperRouter_Reconcile(t *testing.T) { func() fixture { ti := newTestIngress() ti.Annotations["something"] = "changed" - _, err := mocks.kubeClient.NetworkingV1beta1().Ingresses("default").Update( + _, err := mocks.kubeClient.NetworkingV1().Ingresses("default").Update( context.TODO(), ti, metav1.UpdateOptions{}) assert.NoError(err) return mocks @@ -60,21 +60,21 @@ func TestSkipperRouter_Reconcile(t *testing.T) { } assert.NoError(router.Reconcile(mocks.ingressCanary)) canaryName := fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get( + inCanary, err := router.kubeClient.NetworkingV1().Ingresses("default").Get( context.TODO(), canaryName, metav1.GetOptions{}) assert.NoError(err) // test initialisation assert.JSONEq(`{ "podinfo-primary": 100, "podinfo-canary": 0 }`, inCanary.Annotations["zalando.org/backend-weights"]) - assert.Equal("podinfo-primary", inCanary.Spec.Rules[0].HTTP.Paths[0].Backend.ServiceName, "backend flipped over") - assert.Equal("podinfo-canary", inCanary.Spec.Rules[0].HTTP.Paths[1].Backend.ServiceName, "backend flipped over") + assert.Equal("podinfo-primary", inCanary.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name, "backend flipped over") + assert.Equal("podinfo-canary", inCanary.Spec.Rules[0].HTTP.Paths[1].Backend.Service.Name, "backend flipped over") assert.Len(inCanary.Spec.Rules[0].HTTP.Paths, 2) - inApex, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get( + inApex, err := router.kubeClient.NetworkingV1().Ingresses("default").Get( context.TODO(), mocks.ingressCanary.Spec.IngressRef.Name, metav1.GetOptions{}) assert.NoError(err) - assert.Equal(inCanary.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort, - inApex.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort, "canary backend not cloned") - assert.Equal(inCanary.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort, - inCanary.Spec.Rules[0].HTTP.Paths[1].Backend.ServicePort, "canary backend not cloned") + assert.Equal(inCanary.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Port.Number, + inApex.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Port.Number, "canary backend not cloned") + assert.Equal(inCanary.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Port.Number, + inCanary.Spec.Rules[0].HTTP.Paths[1].Backend.Service.Port.Number, "canary backend not cloned") }) } } @@ -107,7 +107,7 @@ func TestSkipperRouter_GetSetRoutes(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { assert.NoError(router.SetRoutes(mocks.ingressCanary, tt.primary, tt.canary, false)) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get( + inCanary, err := router.kubeClient.NetworkingV1().Ingresses("default").Get( context.TODO(), fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name), metav1.GetOptions{}) assert.NoError(err) assert.JSONEq(fmt.Sprintf(`{"podinfo-primary": %d,"podinfo-canary": %d}`, tt.primary, tt.canary), diff --git a/test/nginx/install.sh b/test/nginx/install.sh index 672b11af..63da0c6b 100755 --- a/test/nginx/install.sh +++ b/test/nginx/install.sh @@ -2,7 +2,7 @@ set -o errexit -NGINX_HELM_VERSION=3.15.2 # ingress v0.41.2 +NGINX_HELM_VERSION=3.31.0 # ingress v0.46.0 REPO_ROOT=$(git rev-parse --show-toplevel) mkdir -p ${REPO_ROOT}/bin diff --git a/test/nginx/test-canary.sh b/test/nginx/test-canary.sh index b2a166ed..04a2129f 100755 --- a/test/nginx/test-canary.sh +++ b/test/nginx/test-canary.sh @@ -8,7 +8,7 @@ set -o errexit REPO_ROOT=$(git rev-parse --show-toplevel) cat <>> Create metric templates' @@ -98,7 +102,7 @@ spec: kind: Deployment name: podinfo ingressRef: - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress name: podinfo progressDeadlineSeconds: 60 @@ -198,7 +202,7 @@ echo '✔ Canary promotion test passed' echo 'Testing original ingress update after canary promotion to pass validation webhook' cat <>> Creating ingress' cat <>> Creating canary' @@ -41,7 +45,7 @@ spec: kind: Deployment name: podinfo ingressRef: - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress name: podinfo-ingress service: