Repository: zalando-incubator/kube-ingress-aws-controller
Pull request #515 (2022-06-22 09:50:10)

Limit ingress support to only networking.k8s.io/v1
Given the deprecation of `extensions/v1beta1` and `networking.k8s.io/v1beta1`,
remove support for them.


Patch:
diff --git a/README.md b/README.md
index 3746e9c..e43f5c5 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 to >=v0.15.0
+
+Version `v0.15.0` removes support for deprecated Ingress versions
+`extensions/v1beta1` and `networking.k8s.io/v1beta1`.
+
 ### <v0.14.0 to >=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 1ec829a..2048935 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-v0.14
+v0.15
diff --git a/controller.go b/controller.go
index c571076..d8470a6 100644
--- a/controller.go
+++ b/controller.go
@@ -179,8 +179,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.IngressAPIVersionNetworkingV1).EnumVar(&ingressAPIVersion, kubernetes.IngressAPIVersionNetworking, kubernetes.IngressAPIVersionExtensions, kubernetes.IngressAPIVersionNetworkingV1)
 	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 e1da9fc..cc61a0a 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"


Test patch:
diff --git a/kubernetes/ingress_test.go b/kubernetes/ingress_test.go
index a33460b..89dc002 100644
--- a/kubernetes/ingress_test.go
+++ b/kubernetes/ingress_test.go
@@ -16,7 +16,7 @@ import (
 
 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)
 		_, err := io.Copy(rw, f)
@@ -30,35 +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 {
-		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 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)
-		_, err := io.Copy(rw, f)
-		require.NoError(t, err)
-	}))
-	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 {
diff --git a/kubernetes/testdata/fixture01.json b/kubernetes/testdata/fixture01.json
index 36bc02a..4301c7b 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,
diff --git a/worker_test.go b/worker_test.go
index 91e9ebb..bb0ff98 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,