Skip to content

Commit

Permalink
Remove Ingress API selection code (#4643)
Browse files Browse the repository at this point in the history
* chore(docs) add #4641 changelog entry

* chore(controllers) remove Ingress API selection

Remove Ingress API selection in favor of simply honoring the CLI disable
flag.

Support for Ingress versions other than networking/v1 was removed in
#3867. The API
selection code was only selecting between networking/v1 and nothing.
Future Kubernetes versions are not expected to abruptly remove the older
API versions if they introduce new Ingress versions, so this selection
code should not be necessary in the future.
  • Loading branch information
rainest authored Sep 12, 2023
1 parent e87afbc commit 064bf4e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 164 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ Adding a new version? You'll need three changes:
`/status` from Kong Gateway.
This happens when Gateway is responding with a 50x HTTP status code.
[#4627](https://github.com/Kong/kubernetes-ingress-controller/issues/4627)
- Ensure the API server is available at startup and do not disable CRD
controllers if Kong CRDs are unavailable. Do not disable the Ingress
controller if the Ingress API is unavailable. This avoids incorrectly
deleting existing configuration during an API server restart.
[#4641](https://github.com/Kong/kubernetes-ingress-controller/issues/4641)
[#4643](https://github.com/Kong/kubernetes-ingress-controller/issues/4643)

## [2.11.1]

Expand Down
66 changes: 0 additions & 66 deletions internal/manager/conditions.go

This file was deleted.

81 changes: 0 additions & 81 deletions internal/manager/conditions_test.go

This file was deleted.

17 changes: 4 additions & 13 deletions internal/manager/controllerdef.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package manager

import (
"context"
"fmt"
"reflect"

"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -67,15 +66,7 @@ func setupControllers(
featureGates map[string]bool,
kongAdminAPIEndpointsNotifier configuration.EndpointsNotifier,
adminAPIsDiscoverer configuration.AdminAPIsDiscoverer,
) ([]ControllerDef, error) {
restMapper := mgr.GetClient().RESTMapper()

// Choose the best API version of Ingress to inform which ingress controller to enable.
ingressConditions, err := NewIngressControllersConditions(c, restMapper)
if err != nil {
return nil, fmt.Errorf("ingress version picker failed: %w", err)
}

) []ControllerDef {
referenceIndexers := ctrlref.NewCacheIndexers()

controllers := []ControllerDef{
Expand All @@ -97,7 +88,7 @@ func setupControllers(
// Core API Controllers
// ---------------------------------------------------------------------------
{
Enabled: ingressConditions.IngressClassNetV1Enabled(),
Enabled: c.IngressClassNetV1Enabled,
Controller: &configuration.NetV1IngressClassReconciler{
Client: mgr.GetClient(),
Log: ctrl.LoggerFrom(ctx).WithName("controllers").WithName("IngressClass").WithName("netv1"),
Expand All @@ -107,7 +98,7 @@ func setupControllers(
},
},
{
Enabled: ingressConditions.IngressNetV1Enabled(),
Enabled: c.IngressNetV1Enabled,
Controller: &configuration.NetV1IngressReconciler{
Client: mgr.GetClient(),
Log: ctrl.LoggerFrom(ctx).WithName("controllers").WithName("Ingress").WithName("netv1"),
Expand Down Expand Up @@ -445,7 +436,7 @@ func setupControllers(
},
}

return controllers, nil
return controllers
}

// baseGatewayCRDs returns a slice of base CRDs required for running all the Gateway API controllers.
Expand Down
5 changes: 1 addition & 4 deletions internal/manager/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func Run(ctx context.Context, c *Config, diagnostic util.ConfigDumpDiagnostic, d
}

setupLog.Info("Starting Enabled Controllers")
controllers, err := setupControllers(
controllers := setupControllers(
ctx,
mgr,
dataplaneClient,
Expand All @@ -235,9 +235,6 @@ func Run(ctx context.Context, c *Config, diagnostic util.ConfigDumpDiagnostic, d
clientsManager,
adminAPIsDiscoverer,
)
if err != nil {
return fmt.Errorf("unable to setup controller as expected %w", err)
}
for _, c := range controllers {
if err := c.MaybeSetupWithManager(mgr); err != nil {
return fmt.Errorf("unable to create controller %q: %w", c.Name(), err)
Expand Down

0 comments on commit 064bf4e

Please sign in to comment.