Skip to content

Commit

Permalink
feat: add support for single controller, multi gateway deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Jan 17, 2023
1 parent aa679e7 commit 1159f64
Show file tree
Hide file tree
Showing 16 changed files with 1,490 additions and 268 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,18 @@ Adding a new version? You'll need three changes:
### Added

- Store status of whether configuration succedded or failed for Kubernetes
- Store status of whether configuration succedded or failed for Kubernetes
objects in dataplane client and publish the events to let controllers know
if the controlled objects succeeded or failed to be translated to Kong
if the controlled objects succeeded or failed to be translated to Kong
configuration.
[#3359](https:/Kong/kubernetes-ingress-controller/pull/3359)
[#3359](https:/Kong/kubernetes-ingress-controller/pull/3359)
- Added `version` command
[#3379](https:/Kong/kubernetes-ingress-controller/pull/3379)
[#3379](https:/Kong/kubernetes-ingress-controller/pull/3379)
- Added possibility to configure multiple Kong Gateways through the
`--kong-admin-url` CLI flag (which can be specified multiple times) or through
a corresponding environment variable `CONTROLLER_KONG_ADMIN_URL` (which can
specify multiple values separated by a comma).
[#3268](https:/Kong/kubernetes-ingress-controller/pull/3268)

### Fixed

Expand Down
23 changes: 18 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ require (
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/cockroachdb/errors v1.9.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/getsentry/sentry-go v0.13.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/sourcegraph/sourcegraph/lib v0.0.0-20221216004406-749998a2ac74 // indirect
go.uber.org/atomic v1.10.0 // indirect
)

require (
cloud.google.com/go/compute v1.14.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
Expand Down Expand Up @@ -104,11 +116,11 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
Expand All @@ -128,6 +140,7 @@ require (
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shirou/gopsutil/v3 v3.22.11 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sourcegraph/conc v0.1.0
github.com/spf13/cast v1.5.0 // indirect
github.com/ssgelm/cookiejarparser v1.0.1 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
Expand All @@ -143,12 +156,12 @@ require (
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/multierr v1.8.0
golang.org/x/crypto v0.3.0 // indirect
golang.org/x/exp v0.0.0-20220407100705-7b9b53b0aca4 // indirect
golang.org/x/exp v0.0.0-20220407100705-7b9b53b0aca4
golang.org/x/mod v0.6.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sync v0.1.0
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
Expand Down
170 changes: 164 additions & 6 deletions go.sum

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions internal/cmd/rootcmd/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,42 @@ func TestBindEnvVars(t *testing.T) {
assert.NoError(t, err)
}

func TestBindEnvVarsSlice(t *testing.T) {
t.Run("set by flags", func(t *testing.T) {
cmd := &cobra.Command{
PreRunE: bindEnvVars,
Run: func(cmd *cobra.Command, args []string) {},
}

ss := cmd.Flags().StringSlice("flag-string-slice", []string{"default"}, "No description")

t.Setenv("CONTROLLER_FLAG_STRING_SLICE", "q,w,e,r,t,y")

cmd.SetArgs([]string{
"--flag-string-slice=1",
"--flag-string-slice=2",
"--flag-string-slice=3",
})
assert.NoError(t, cmd.Execute())
assert.Equal(t, []string{"1", "2", "3"}, *ss)
})

t.Run("set by env", func(t *testing.T) {
cmd := &cobra.Command{
PreRunE: bindEnvVars,
Run: func(cmd *cobra.Command, args []string) {},
}

ss := cmd.Flags().StringSlice("flag-string-slice", []string{"default"}, "No description")

t.Setenv("CONTROLLER_FLAG_STRING_SLICE", "q,w,e,r,t,y")

cmd.SetArgs([]string{})
assert.NoError(t, cmd.Execute())
assert.Equal(t, []string{"q", "w", "e", "r", "t", "y"}, *ss)
})
}

func TestBindEnvVarsValidation(t *testing.T) {
cmd := &cobra.Command{
PreRunE: bindEnvVars,
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/gateway/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
debug(log, gateway, "failed to delete object from data-plane, requeuing")
return ctrl.Result{}, err
}
debug(log, gateway, "ensured object was removed from the data-plane (if ever present)")
debug(log, gateway, "ensured gateway was removed from the data-plane (if ever present)")
return ctrl.Result{}, nil
}
if gwc.Spec.ControllerName != ControllerName {
Expand All @@ -331,7 +331,7 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
debug(log, gateway, "failed to delete object from data-plane, requeuing")
return ctrl.Result{}, err
}
debug(log, gateway, "ensured object was removed from the data-plane (if ever present)")
debug(log, gateway, "ensured gateway was removed from the data-plane (if ever present)")
return ctrl.Result{}, nil
}

Expand Down
Loading

0 comments on commit 1159f64

Please sign in to comment.