From 3ccfdcfcb7e258627554cdcddc2dad3770a14672 Mon Sep 17 00:00:00 2001 From: Katyanna Moura Date: Wed, 22 Jun 2022 11:33:38 +0200 Subject: [PATCH 1/5] Limit ingress support to only networking.k8s.io/v1 Given the deprecation of extensions/v1beta1 and networking.k8s.io/v1beta1, remove support for them. Signed-off-by: Katyanna Moura --- controller.go | 2 +- kubernetes/ingress.go | 3 +-- kubernetes/ingress_test.go | 27 --------------------------- kubernetes/testdata/fixture01.json | 14 +++++++------- 4 files changed, 9 insertions(+), 37 deletions(-) diff --git a/controller.go b/controller.go index 33f488a7..7d4c13a8 100644 --- a/controller.go +++ b/controller.go @@ -176,7 +176,7 @@ func loadSettings() error { kingpin.Flag("nlb-http-enabled", "Enable HTTP (port 80) for Network Load Balancers. By default this is disabled as NLB can't provide HTTP -> HTTPS redirect."). Default("false").BoolVar(&nlbHTTPEnabled) kingpin.Flag("ingress-api-version", "APIversion used for listing/updating ingresses."). - Default(kubernetes.IngressAPIVersionNetworkingV1).EnumVar(&ingressAPIVersion, kubernetes.IngressAPIVersionNetworking, kubernetes.IngressAPIVersionExtensions, kubernetes.IngressAPIVersionNetworkingV1) + Default(kubernetes.IngressAPIVersionNetworking).EnumVar(&ingressAPIVersion, kubernetes.IngressAPIVersionNetworking) kingpin.Flag("deny-internal-domains", "Sets a rule on ALB's Listeners that denies requests with the Host header as a internal domain. Domains can be set with the -internal-domains flag."). Default("false").BoolVar(&denyInternalDomains) kingpin.Flag("internal-domains", "Define the internal domains to be blocked when -deny-internal-domains is set to true. Set it multiple times for multiple domains. The maximum size of each name is 128 characters. The following wildcard characters are supported: * (matches 0 or more characters) and ? (matches exactly 1 character)."). diff --git a/kubernetes/ingress.go b/kubernetes/ingress.go index e1da9fcb..cc61a0a7 100644 --- a/kubernetes/ingress.go +++ b/kubernetes/ingress.go @@ -63,8 +63,7 @@ const ( // ingressALBIPAddressType is used in external-dns, https://github.com/kubernetes-incubator/external-dns/pull/1079 ingressALBIPAddressType = "alb.ingress.kubernetes.io/ip-address-type" IngressAPIVersionExtensions = "extensions/v1beta1" - IngressAPIVersionNetworking = "networking.k8s.io/v1beta1" - IngressAPIVersionNetworkingV1 = "networking.k8s.io/v1" + IngressAPIVersionNetworking = "networking.k8s.io/v1" ingressListResource = "/apis/%s/ingresses" ingressPatchStatusResource = "/apis/%s/namespaces/%s/ingresses/%s/status" ingressCertificateARNAnnotation = "zalando.org/aws-load-balancer-ssl-cert" diff --git a/kubernetes/ingress_test.go b/kubernetes/ingress_test.go index 204681b8..acf3933d 100644 --- a/kubernetes/ingress_test.go +++ b/kubernetes/ingress_test.go @@ -41,33 +41,6 @@ func TestListIngresses(t *testing.T) { } } -func TestListIngressesV1(t *testing.T) { - testServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - f, _ := os.Open("testdata/fixture03.json") - defer f.Close() - rw.WriteHeader(http.StatusOK) - io.Copy(rw, f) - })) - defer testServer.Close() - kubeClient, _ := newSimpleClient(&Config{BaseURL: testServer.URL}, false) - ingressClient := &ingressClient{apiVersion: IngressAPIVersionNetworkingV1} - want := newList(IngressAPIVersionNetworkingV1, - newIngress("fixture01", nil, "", "example.org", "fixture01", IngressAPIVersionNetworkingV1), - newIngress("fixture02", map[string]string{ingressClassAnnotation: "skipper"}, "", "skipper.example.org", "fixture02", IngressAPIVersionNetworkingV1), - newIngress("fixture03", map[string]string{ingressClassAnnotation: "other"}, "", "other.example.org", "fixture03", IngressAPIVersionNetworkingV1), - newIngress("fixture04", nil, "another", "another.example.org", "fixture04", IngressAPIVersionNetworkingV1), - ) - got, err := ingressClient.listIngress(kubeClient) - if err != nil { - t.Errorf("unexpected error from listIngresses: %v", err) - } else { - if !reflect.DeepEqual(got, want) { - t.Errorf("unexpected result from listIngresses. wanted %v, got %v", want, got) - t.Errorf("%v", cmp.Diff(want, got)) - } - } -} - func TestListIngressFailureScenarios(t *testing.T) { for _, test := range []struct { statusCode int diff --git a/kubernetes/testdata/fixture01.json b/kubernetes/testdata/fixture01.json index 36bc02a1..4301c7be 100644 --- a/kubernetes/testdata/fixture01.json +++ b/kubernetes/testdata/fixture01.json @@ -1,8 +1,8 @@ { "kind": "IngressList", - "apiVersion": "networking.k8s.io/v1beta1", + "apiVersion": "networking.k8s.io/v1", "metadata": { - "selfLink": "/apis/networking.k8s.io/v1beta1/ingresses", + "selfLink": "/apis/networking.k8s.io/v1/ingresses", "resourceVersion": "42" }, "items": [ @@ -10,7 +10,7 @@ "metadata": { "name": "fixture01", "namespace": "default", - "selfLink": "/apis/networking.k8s.io/v1beta1/namespaces/default/ingresses/fixture01", + "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/ingresses/fixture01", "uid": "fixture01", "resourceVersion": "42", "generation": 1, @@ -31,7 +31,7 @@ "metadata": { "name": "fixture02", "namespace": "default", - "selfLink": "/apis/networking.k8s.io/v1beta1/namespaces/default/ingresses/fixture02", + "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/ingresses/fixture02", "uid": "fixture02", "resourceVersion": "42", "generation": 1, @@ -53,7 +53,7 @@ "metadata": { "name": "fixture03", "namespace": "default", - "selfLink": "/apis/networking.k8s.io/v1beta1/namespaces/default/ingresses/fixture03", + "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/ingresses/fixture03", "uid": "fixture03", "resourceVersion": "42", "generation": 1, @@ -75,7 +75,7 @@ "metadata": { "name": "fixture04", "namespace": "default", - "selfLink": "/apis/networking.k8s.io/v1beta1/namespaces/default/ingresses/fixture04", + "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/ingresses/fixture04", "uid": "fixture04", "resourceVersion": "42", "generation": 1, @@ -99,7 +99,7 @@ "metadata": { "name": "fixture05", "namespace": "default", - "selfLink": "/apis/networking.k8s.io/v1beta1/namespaces/default/ingresses/fixture05", + "selfLink": "/apis/networking.k8s.io/v1/namespaces/default/ingresses/fixture05", "uid": "fixture05", "resourceVersion": "42", "generation": 1, From 362d007d4aa611468e7e6a928687d6ebd17ead82 Mon Sep 17 00:00:00 2001 From: Katyanna Moura Date: Wed, 22 Jun 2022 11:54:33 +0200 Subject: [PATCH 2/5] Remove flag that allowed Ingress version choice Signed-off-by: Katyanna Moura --- controller.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/controller.go b/controller.go index 7d4c13a8..83843fc4 100644 --- a/controller.go +++ b/controller.go @@ -175,8 +175,6 @@ func loadSettings() error { Default("false").BoolVar(&nlbCrossZone) kingpin.Flag("nlb-http-enabled", "Enable HTTP (port 80) for Network Load Balancers. By default this is disabled as NLB can't provide HTTP -> HTTPS redirect."). Default("false").BoolVar(&nlbHTTPEnabled) - kingpin.Flag("ingress-api-version", "APIversion used for listing/updating ingresses."). - Default(kubernetes.IngressAPIVersionNetworking).EnumVar(&ingressAPIVersion, kubernetes.IngressAPIVersionNetworking) kingpin.Flag("deny-internal-domains", "Sets a rule on ALB's Listeners that denies requests with the Host header as a internal domain. Domains can be set with the -internal-domains flag."). Default("false").BoolVar(&denyInternalDomains) kingpin.Flag("internal-domains", "Define the internal domains to be blocked when -deny-internal-domains is set to true. Set it multiple times for multiple domains. The maximum size of each name is 128 characters. The following wildcard characters are supported: * (matches 0 or more characters) and ? (matches exactly 1 character)."). From a52a2397fda302d5118e8f6dec96ea54284a5f8f Mon Sep 17 00:00:00 2001 From: Katyanna Moura Date: Tue, 5 Dec 2023 21:06:39 +0100 Subject: [PATCH 3/5] Update Ingress Test V1 Signed-off-by: Katyanna Moura --- kubernetes/ingress_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kubernetes/ingress_test.go b/kubernetes/ingress_test.go index acf3933d..89dc002a 100644 --- a/kubernetes/ingress_test.go +++ b/kubernetes/ingress_test.go @@ -11,14 +11,16 @@ import ( "time" "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" ) func TestListIngresses(t *testing.T) { testServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - f, _ := os.Open("testdata/fixture01.json") + f, _ := os.Open("testdata/fixture03.json") defer f.Close() rw.WriteHeader(http.StatusOK) - io.Copy(rw, f) + _, err := io.Copy(rw, f) + require.NoError(t, err) })) defer testServer.Close() kubeClient, _ := newSimpleClient(&Config{BaseURL: testServer.URL}, false) @@ -28,7 +30,6 @@ func TestListIngresses(t *testing.T) { newIngress("fixture02", map[string]string{ingressClassAnnotation: "skipper"}, "", "skipper.example.org", "fixture02", IngressAPIVersionNetworking), newIngress("fixture03", map[string]string{ingressClassAnnotation: "other"}, "", "other.example.org", "fixture03", IngressAPIVersionNetworking), newIngress("fixture04", nil, "another", "another.example.org", "fixture04", IngressAPIVersionNetworking), - newIngress("fixture05", map[string]string{ingressClassAnnotation: "yet-another-ignored"}, "yet-another", "yet-another.example.org", "fixture05", IngressAPIVersionNetworking), ) got, err := ingressClient.listIngress(kubeClient) if err != nil { From e9794ddd2ec1571b343dc4c7076027b98e2bad8e Mon Sep 17 00:00:00 2001 From: Katyanna Moura Date: Thu, 18 Jan 2024 10:35:02 +0100 Subject: [PATCH 4/5] Fix var name Signed-off-by: Katyanna Moura --- worker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker_test.go b/worker_test.go index 91e9ebb5..bb0ff981 100644 --- a/worker_test.go +++ b/worker_test.go @@ -506,7 +506,7 @@ func TestResourceConversionOneToOne(tt *testing.T) { sslPolicy := "ELBSecurityPolicy-2016-08" clusterLocalDomain := "" - ingressAPIVersion := kubernetes.IngressAPIVersionNetworkingV1 + ingressAPIVersion := kubernetes.IngressAPIVersionNetworking k, err := kubernetes.NewAdapter( kubeConfig, From d9390b61d81c893f02669e83b3a67e27b4fa5ee6 Mon Sep 17 00:00:00 2001 From: Katyanna Moura Date: Mon, 29 Jan 2024 14:04:40 +0100 Subject: [PATCH 5/5] Upgrade version to v0.15 Signed-off-by: Katyanna Moura --- README.md | 5 +++++ VERSION | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3746e9cc..e43f5c5f 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,11 @@ This information is used to manage AWS resources for each ingress objects of the ## Upgrade +### =v0.15.0 + +Version `v0.15.0` removes support for deprecated Ingress versions +`extensions/v1beta1` and `networking.k8s.io/v1beta1`. + ### =v0.14.0 Version `v0.14.0` makes `target-access-mode` flag required to make upgrading users aware of the [issue](https://github.com/zalando-incubator/kube-ingress-aws-controller/issues/507). diff --git a/VERSION b/VERSION index 1ec829a2..20489352 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.14 +v0.15