Skip to content

Commit

Permalink
chore: remove support for netv1beta1.Ingress (#3867)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek authored May 11, 2023
1 parent 91f985e commit 35de761
Show file tree
Hide file tree
Showing 32 changed files with 1,201 additions and 2,324 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ Adding a new version? You'll need three changes:

### Deprecated

- Removed support for extensions/v1beta1 Ingress which was removed in kubernetes 1.22.
- Removed support for `extensions/v1beta1` `Ingress` which was removed in kubernetes 1.22.
At the same time deprecate `--enable-controller-ingress-extensionsv1beta1` CLI flag.
[#3710](https://github.com/Kong/kubernetes-ingress-controller/pull/3710)

- Removed support for `networking.k8s.io/v1beta1` `Ingress` which was removed in kubernetes 1.22.
At the same time deprecate `--enable-controller-ingress-networkingv1beta1` CLI flag.
[#3867](https://github.com/Kong/kubernetes-ingress-controller/pull/3867)

## [2.9.3]

> Release date: 2023-04-17
Expand Down
22 changes: 2 additions & 20 deletions hack/generators/controllers/networking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import (
const (
outputFile = "../../internal/controllers/configuration/zz_generated_controllers.go"

corev1 = "k8s.io/api/core/v1"
netv1 = "k8s.io/api/networking/v1"
netv1beta1 = "k8s.io/api/networking/v1beta1"
corev1 = "k8s.io/api/core/v1"
netv1 = "k8s.io/api/networking/v1"

kongv1 = "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1"
kongv1beta1 = "github.com/kong/kubernetes-ingress-controller/v2/api/configuration/v1beta1"
Expand Down Expand Up @@ -89,22 +88,6 @@ var inputControllersNeeded = &typesNeeded{
AcceptsIngressClassNameSpec: false,
RBACVerbs: []string{"get", "list", "watch"},
},
typeNeeded{
Group: "networking.k8s.io",
Version: "v1beta1",
Kind: "Ingress",
PackageImportAlias: "netv1beta1",
PackageAlias: "NetV1Beta1",
Package: netv1beta1,
Plural: "ingresses",
CacheType: "IngressV1beta1",
NeedsStatusPermissions: true,
CapableOfStatusUpdates: true,
AcceptsIngressClassNameAnnotation: true,
AcceptsIngressClassNameSpec: true,
NeedsUpdateReferences: true,
RBACVerbs: []string{"get", "list", "watch"},
},
typeNeeded{
Group: "configuration.konghq.com",
Version: "v1",
Expand Down Expand Up @@ -378,7 +361,6 @@ import (
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
18 changes: 0 additions & 18 deletions internal/controllers/configuration/object_references.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand All @@ -32,8 +31,6 @@ func updateReferredObjects(
referredSecretList = listCoreV1ServiceReferredSecrets(obj)
case *netv1.Ingress:
referredSecretList = listNetV1IngressReferredSecrets(obj)
case *netv1beta1.Ingress:
referredSecretList = listNetV1beta1IngressReferredSecrets(obj)
case *kongv1.KongPlugin:
referredSecretList = listKongPluginReferredSecrets(obj)
case *kongv1.KongClusterPlugin:
Expand Down Expand Up @@ -83,21 +80,6 @@ func listNetV1IngressReferredSecrets(ingress *netv1.Ingress) []types.NamespacedN
return referredSecretNames
}

func listNetV1beta1IngressReferredSecrets(ingress *netv1beta1.Ingress) []types.NamespacedName {
referredSecretNames := make([]types.NamespacedName, 0, len(ingress.Spec.TLS))
for _, tls := range ingress.Spec.TLS {
if tls.SecretName == "" {
continue
}
nsName := types.NamespacedName{
Namespace: ingress.Namespace,
Name: tls.SecretName,
}
referredSecretNames = append(referredSecretNames, nsName)
}
return referredSecretNames
}

func listKongPluginReferredSecrets(plugin *kongv1.KongPlugin) []types.NamespacedName {
referredSecretNames := make([]types.NamespacedName, 0, 1)
if plugin.ConfigFrom != nil {
Expand Down
196 changes: 0 additions & 196 deletions internal/controllers/configuration/zz_generated_controllers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 0 additions & 29 deletions internal/controllers/utils/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
Expand Down Expand Up @@ -36,27 +35,13 @@ func UpdateLoadBalancerIngress(
obj.Status.LoadBalancer.Ingress = netV1ToCoreV1LoadBalancerIngress(newAddresses)
case *kongv1beta1.UDPIngress:
obj.Status.LoadBalancer.Ingress = netV1ToCoreV1LoadBalancerIngress(newAddresses)
case *netv1beta1.Ingress:
obj.Status.LoadBalancer.Ingress = netV1ToV1beta1LoadBalancerIngress(newAddresses)
default:
return false, fmt.Errorf("unsupported ingress type: %T", obj)
}

return true, nil
}

func netV1ToV1beta1LoadBalancerIngress(in []netv1.IngressLoadBalancerIngress) []netv1beta1.IngressLoadBalancerIngress {
out := make([]netv1beta1.IngressLoadBalancerIngress, 0, len(in))
for _, i := range in {
out = append(out, netv1beta1.IngressLoadBalancerIngress{
IP: i.IP,
Hostname: i.Hostname,
// consciously omitting ports as we do not populate them
})
}
return out
}

func netV1ToCoreV1LoadBalancerIngress(in []netv1.IngressLoadBalancerIngress) []corev1.LoadBalancerIngress {
out := make([]corev1.LoadBalancerIngress, 0, len(in))
for _, i := range in {
Expand All @@ -77,25 +62,11 @@ func ingressToNetV1LoadBalancerIngressStatus(in any) ([]netv1.IngressLoadBalance
return coreV1ToNetV1LoadBalancerIngress(obj.Status.LoadBalancer.Ingress), nil
case *kongv1beta1.UDPIngress:
return coreV1ToNetV1LoadBalancerIngress(obj.Status.LoadBalancer.Ingress), nil
case *netv1beta1.Ingress:
return v1beta1ToNetV1LoadBalancerIngress(obj.Status.LoadBalancer.Ingress), nil
default:
return nil, fmt.Errorf("unsupported ingress type: %T", obj)
}
}

func v1beta1ToNetV1LoadBalancerIngress(in []netv1beta1.IngressLoadBalancerIngress) []netv1.IngressLoadBalancerIngress {
out := make([]netv1.IngressLoadBalancerIngress, 0, len(in))
for _, i := range in {
out = append(out, netv1.IngressLoadBalancerIngress{
IP: i.IP,
Hostname: i.Hostname,
// consciously omitting ports as we do not populate them
})
}
return out
}

func coreV1ToNetV1LoadBalancerIngress(in []corev1.LoadBalancerIngress) []netv1.IngressLoadBalancerIngress {
out := make([]netv1.IngressLoadBalancerIngress, 0, len(in))
for _, i := range in {
Expand Down
9 changes: 4 additions & 5 deletions internal/controllers/utils/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
netv1beta1 "k8s.io/api/networking/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1"
Expand All @@ -34,10 +33,10 @@ func TestUpdateLoadBalancerIngress(t *testing.T) {
},
},
},
&netv1beta1.Ingress{
Status: netv1beta1.IngressStatus{
LoadBalancer: netv1beta1.IngressLoadBalancerStatus{
Ingress: []netv1beta1.IngressLoadBalancerIngress{
&netv1.Ingress{
Status: netv1.IngressStatus{
LoadBalancer: netv1.IngressLoadBalancerStatus{
Ingress: []netv1.IngressLoadBalancerIngress{
{
IP: oldIP,
Hostname: oldHostname,
Expand Down
Loading

0 comments on commit 35de761

Please sign in to comment.