Skip to content

Commit 313234c

Browse files
authored
feat: --konnect-disable-consumer-sync flag (#6313)
* feat: --konnect-disable-consumer-sync flag Signed-off-by: Mattia Lavacca <[email protected]> * address review comments Signed-off-by: Mattia Lavacca <[email protected]> --------- Signed-off-by: Mattia Lavacca <[email protected]>
1 parent ffd9e9e commit 313234c

File tree

7 files changed

+23
-5
lines changed

7 files changed

+23
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ Adding a new version? You'll need three changes:
9999

100100
- `KongCustomEntity` is now supported by the `FallbackConfiguration` feature.
101101
[#6286](https://github.com/Kong/kubernetes-ingress-controller/pull/6286)
102+
- It is now possible to disable synchronization of consumers to Konnect through the
103+
flag `--konnect-disable-consumers-sync`.
104+
[#6313](https://github.com/Kong/kubernetes-ingress-controller/pull/6313)
102105

103106
### Fixed
104107

docs/cli-arguments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
| `--kong-workspace` | `string` | Kong Enterprise workspace to configure. Leave this empty if not using Kong workspaces. | |
6868
| `--konnect-address` | `string` | Base address of Konnect API. | `https://us.kic.api.konghq.com` |
6969
| `--konnect-control-plane-id` | `string` | An ID of a control plane that is to be synchronized with data plane configuration. | |
70+
| `--konnect-disable-consumers-sync` | `bool` | Disable synchronization of consumers with Konnect. | `false` |
7071
| `--konnect-initial-license-polling-period` | `duration` | Polling period to be used before the first license is retrieved. | `1m0s` |
7172
| `--konnect-license-polling-period` | `duration` | Polling period to be used after the first license is retrieved. | `12h0m0s` |
7273
| `--konnect-licensing-enabled` | `bool` | Retrieve licenses from Konnect if available. Overrides licenses provided via the environment. | `false` |

internal/adminapi/client.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,32 @@ func NewTestClient(address string) (*Client, error) {
5252

5353
type KonnectClient struct {
5454
Client
55-
backoffStrategy UpdateBackoffStrategy
55+
consumersSyncDisabled bool
56+
backoffStrategy UpdateBackoffStrategy
5657
}
5758

5859
// NewKonnectClient creates an Admin API client that is to be used with a Konnect Control Plane Admin API.
59-
func NewKonnectClient(c *kong.Client, controlPlane string) *KonnectClient {
60+
func NewKonnectClient(c *kong.Client, controlPlane string, consumersSyncDisabled bool) *KonnectClient {
6061
return &KonnectClient{
6162
Client: Client{
6263
adminAPIClient: c,
6364
isKonnect: true,
6465
konnectControlPlane: controlPlane,
6566
pluginSchemaStore: util.NewPluginSchemaStore(c),
6667
},
67-
backoffStrategy: NewKonnectBackoffStrategy(clock.System{}),
68+
backoffStrategy: NewKonnectBackoffStrategy(clock.System{}),
69+
consumersSyncDisabled: consumersSyncDisabled,
6870
}
6971
}
7072

7173
func (c *KonnectClient) BackoffStrategy() UpdateBackoffStrategy {
7274
return c.backoffStrategy
7375
}
7476

77+
func (c *KonnectClient) ConsumersSyncDisabled() bool {
78+
return c.consumersSyncDisabled
79+
}
80+
7581
// AdminAPIClient returns an underlying go-kong's Admin API client.
7682
func (c *Client) AdminAPIClient() *kong.Client {
7783
return c.adminAPIClient

internal/adminapi/konnect.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type KonnectConfig struct {
2828
LicenseSynchronizationEnabled bool
2929
InitialLicensePollingPeriod time.Duration
3030
LicensePollingPeriod time.Duration
31+
ConsumersSyncDisabled bool
3132
}
3233

3334
func NewKongClientForKonnectControlPlane(c KonnectConfig) (*KonnectClient, error) {
@@ -59,7 +60,7 @@ func NewKongClientForKonnectControlPlane(c KonnectConfig) (*KonnectClient, error
5960
if err != nil {
6061
return nil, err
6162
}
62-
return NewKonnectClient(client, c.ControlPlaneID), nil
63+
return NewKonnectClient(client, c.ControlPlaneID, c.ConsumersSyncDisabled), nil
6364
}
6465

6566
// EnsureKonnectConnection ensures that the client is able to connect to Konnect.

internal/dataplane/kong_client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,12 @@ func (c *KongClient) maybeSendOutToKonnectClient(
740740
return nil
741741
}
742742

743+
// In case users have many consumers, konnect sync can be very slow and cause dataplane sync issues.
744+
// For this reason, if the --disable-consumers-sync flag is set, we do not send consumers to Konnect.
745+
if konnectClient.ConsumersSyncDisabled() {
746+
s.Consumers = nil
747+
}
748+
743749
if _, err := c.sendToClient(ctx, konnectClient, s, config, isFallback); err != nil {
744750
// In case of an error, we only log it since we don't want the Konnect to affect the basic functionality
745751
// of the controller.

internal/dataplane/kong_client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ func mustSampleKonnectClient(t *testing.T) *adminapi.KonnectClient {
961961
require.NoError(t, err)
962962

963963
rgID := uuid.NewString()
964-
return adminapi.NewKonnectClient(c, rgID)
964+
return adminapi.NewKonnectClient(c, rgID, false)
965965
}
966966

967967
func mapClientsToUrls(clients *mockGatewayClientsProvider) []string {

internal/manager/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ func (c *Config) FlagSet() *pflag.FlagSet {
313313
flagSet.StringVar(&c.Konnect.TLSClient.Key, "konnect-tls-client-key", "", "Konnect TLS client key.")
314314
flagSet.StringVar(&c.Konnect.TLSClient.KeyFile, "konnect-tls-client-key-file", "", "Konnect TLS client key file path.")
315315
flagSet.DurationVar(&c.Konnect.RefreshNodePeriod, "konnect-refresh-node-period", konnect.DefaultRefreshNodePeriod, "Period of uploading status of KIC and controlled Kong instances.")
316+
flagSet.BoolVar(&c.Konnect.ConsumersSyncDisabled, "konnect-disable-consumers-sync", false, "Disable synchronization of consumers with Konnect.")
316317

317318
// Deprecated flags.
318319
flagSet.StringVar(&c.Konnect.ControlPlaneID, "konnect-runtime-group-id", "", "Use --konnect-control-plane-id instead.")

0 commit comments

Comments
 (0)