Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecate --konnect-runtime-group-id flag #4783

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ Adding a new version? You'll need three changes:
- `enable-controller-ingress-extensionsv1beta1`: Has no effect
- `enable-controller-ingress-networkingv1beta1`: Has no effect
[#4770](https://github.com/Kong/kubernetes-ingress-controller/pull/4770)
- `--konnect-runtime-group-id` CLI flag is now deprecated. Please use `--konnect-control-plane-id`
instead.
[#4783](https://github.com/Kong/kubernetes-ingress-controller/pull/4783)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ debug.skaffold:
# port with debugger/IDE of your choice.
#
# To make it work with Konnect, you must provide following files under ./config/variants/konnect/debug:
# * `konnect.env` with CONTROLLER_KONNECT_RUNTIME_GROUP_ID env variable set
# * `konnect.env` with CONTROLLER_KONNECT_CONTROL_PLANE_ID env variable set
# to the UUID of a Runtime Group you have created in Konnect.
czeslavo marked this conversation as resolved.
Show resolved Hide resolved
# * `tls.crt` and `tls.key` with TLS client cerificate and its key (generated by Konnect).
.PHONY: debug.skaffold.konnect
Expand Down
2 changes: 1 addition & 1 deletion config/components/konnect/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
envFrom:
- configMapRef:
# konnect-config ConfigMap is expected to specify:
# * CONTROLLER_KONNECT_RUNTIME_GROUP_ID (required)
# * CONTROLLER_KONNECT_CONTROL_PLANE_ID (required)
# * CONTROLLER_KONNECT_ADDRESS (optional)
name: konnect-config
env:
Expand Down
2 changes: 1 addition & 1 deletion config/variants/konnect/base/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
envFrom:
- configMapRef:
# konnect-config ConfigMap is expected to specify:
# * CONTROLLER_KONNECT_RUNTIME_GROUP_ID (required)
# * CONTROLLER_KONNECT_CONTROL_PLANE_ID (required)
# * CONTROLLER_KONNECT_ADDRESS (optional)
name: konnect-config
env:
Expand Down
2 changes: 1 addition & 1 deletion docs/cli-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
| `--kong-admin-url` | `stringSlice` | Kong Admin URL(s) to connect to in the format "protocol://address:port". More than 1 URL can be provided, in such case the flag should be used multiple times or a corresponding env variable should use comma delimited addresses. | `[http://localhost:8001]` |
| `--kong-workspace` | `string` | Kong Enterprise workspace to configure. Leave this empty if not using Kong workspaces. | |
| `--konnect-address` | `string` | Base address of Konnect API. | `https://us.kic.api.konghq.com` |
| `--konnect-control-plane-id` | `string` | An ID of a control plane that is to be synchronized with data plane configuration. | |
| `--konnect-initial-license-polling-period` | `duration` | Polling period to be used before the first license is retrieved. | `1m0s` |
| `--konnect-license-polling-period` | `duration` | Polling period to be used after the first license is retrieved. | `12h0m0s` |
| `--konnect-licensing-enabled` | `bool` | Retrieve licenses from Konnect if available. Overrides licenses provided via the environment. | `false` |
| `--konnect-refresh-node-period` | `duration` | Period of uploading status of KIC and controlled kong gateway instances. | `1m0s` |
| `--konnect-runtime-group-id` | `string` | An ID of a runtime group that is to be synchronized with data plane configuration. | |
| `--konnect-sync-enabled` | `bool` | Enable synchronization of data plane configuration with a Konnect runtime group. | `false` |
programmer04 marked this conversation as resolved.
Show resolved Hide resolved
| `--konnect-tls-client-cert` | `string` | Konnect TLS client certificate. | |
| `--konnect-tls-client-cert-file` | `string` | Konnect TLS client certificate file path. | |
Expand Down
6 changes: 3 additions & 3 deletions internal/adminapi/konnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type KonnectConfig struct {
// ConfigSynchronizationEnabled is the only toggle we had prior to the addition of the license agent.
// We likely want to combine these into a single Konnect toggle or piggyback off other Konnect functionality.
ConfigSynchronizationEnabled bool
RuntimeGroupID string
ControlPlaneID string
Address string
RefreshNodePeriod time.Duration
TLSClient TLSClientConfig
Expand Down Expand Up @@ -52,7 +52,7 @@ func NewKongClientForKonnectRuntimeGroup(c KonnectConfig) (*KonnectClient, error
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = &tlsConfig
client, err := kong.NewClient(
lo.ToPtr(fmt.Sprintf("%s/%s/%s", c.Address, "kic/api/control-planes", c.RuntimeGroupID)),
lo.ToPtr(fmt.Sprintf("%s/%s/%s", c.Address, "kic/api/control-planes", c.ControlPlaneID)),
&http.Client{
Transport: transport,
},
Expand All @@ -63,7 +63,7 @@ func NewKongClientForKonnectRuntimeGroup(c KonnectConfig) (*KonnectClient, error
// Konnect supports tags, we don't need to verify that.
client.Tags = tagsStub{}

return NewKonnectClient(client, c.RuntimeGroupID), nil
return NewKonnectClient(client, c.ControlPlaneID), nil
}

// EnsureKonnectConnection ensures that the client is able to connect to Konnect.
Expand Down
2 changes: 1 addition & 1 deletion internal/adminapi/konnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNewKongClientForKonnectRuntimeGroup(t *testing.T) {

c, err := adminapi.NewKongClientForKonnectRuntimeGroup(adminapi.KonnectConfig{
ConfigSynchronizationEnabled: true,
RuntimeGroupID: runtimeGroupID,
ControlPlaneID: runtimeGroupID,
Address: "https://us.kic.api.konghq.tech",
TLSClient: adminapi.TLSClientConfig{
Cert: os.Getenv("KONG_TEST_KONNECT_TLS_CLIENT_CERT"),
Expand Down
2 changes: 1 addition & 1 deletion internal/konnect/license/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewClient(cfg adminapi.KonnectConfig) (*Client, error) {

return &Client{
address: cfg.Address,
runtimeGroupID: cfg.RuntimeGroupID,
runtimeGroupID: cfg.ControlPlaneID,
programmer04 marked this conversation as resolved.
Show resolved Hide resolved
httpClient: c,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/konnect/nodes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewClient(cfg adminapi.KonnectConfig) (*Client, error) {

return &Client{
address: cfg.Address,
runtimeGroupID: cfg.RuntimeGroupID,
runtimeGroupID: cfg.ControlPlaneID,
httpClient: c,
}, nil
}
Expand Down
5 changes: 4 additions & 1 deletion internal/manager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (c *Config) FlagSet() *pflag.FlagSet {
flagSet.BoolVar(&c.Konnect.LicenseSynchronizationEnabled, "konnect-licensing-enabled", false, "Retrieve licenses from Konnect if available. Overrides licenses provided via the environment.")
flagSet.DurationVar(&c.Konnect.InitialLicensePollingPeriod, "konnect-initial-license-polling-period", license.DefaultInitialPollingPeriod, "Polling period to be used before the first license is retrieved.")
flagSet.DurationVar(&c.Konnect.LicensePollingPeriod, "konnect-license-polling-period", license.DefaultPollingPeriod, "Polling period to be used after the first license is retrieved.")
flagSet.StringVar(&c.Konnect.RuntimeGroupID, "konnect-runtime-group-id", "", "An ID of a runtime group that is to be synchronized with data plane configuration.")
flagSet.StringVar(&c.Konnect.ControlPlaneID, "konnect-control-plane-id", "", "An ID of a control plane that is to be synchronized with data plane configuration.")
flagSet.StringVar(&c.Konnect.Address, "konnect-address", "https://us.kic.api.konghq.com", "Base address of Konnect API.")
flagSet.StringVar(&c.Konnect.TLSClient.Cert, "konnect-tls-client-cert", "", "Konnect TLS client certificate.")
flagSet.StringVar(&c.Konnect.TLSClient.CertFile, "konnect-tls-client-cert-file", "", "Konnect TLS client certificate file path.")
Expand All @@ -276,6 +276,9 @@ func (c *Config) FlagSet() *pflag.FlagSet {
flagSet.StringSliceVar(&c.IngressAddressesUDP, "publish-status-address-udp", []string{}, "")
_ = flagSet.MarkDeprecated("publish-status-address-udp", "Use --ingress-address-udp instead")

flagSet.StringVar(&c.Konnect.ControlPlaneID, "konnect-runtime-group-id", "", "Use --konnect-control-plane-id instead.")
_ = flagSet.MarkDeprecated("konnect-runtime-group-id", "Use --konnect-control-plane-id instead.")

c.flagSet = flagSet
return flagSet
}
Expand Down
2 changes: 1 addition & 1 deletion internal/manager/config_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (c *Config) validateKonnect() error {
if konnect.Address == "" {
return errors.New("address not specified")
}
if konnect.RuntimeGroupID == "" {
if konnect.ControlPlaneID == "" {
return errors.New("runtime group not specified")
czeslavo marked this conversation as resolved.
Show resolved Hide resolved
}
if konnect.TLSClient.IsZero() {
Expand Down
23 changes: 21 additions & 2 deletions internal/manager/config_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,25 @@ func TestConfigValidatedVars(t *testing.T) {
ExpectedErrorContains: "namespace cannot be empty",
},
},
"--konnect-runtime-group-id": {
{
Input: "5ef731c0-6081-49d6-b3ec-d4f85e58b956",
ExtractValueFn: func(c manager.Config) any {
return c.Konnect.ControlPlaneID
},
ExpectedValue: "5ef731c0-6081-49d6-b3ec-d4f85e58b956",
ExpectedUsageAdditionalMsg: "Flag --konnect-runtime-group-id has been deprecated, Use --konnect-control-plane-id instead.\n",
},
},
"--konnect-control-plane-id": {
{
Input: "5ef731c0-6081-49d6-b3ec-d4f85e58b956",
ExtractValueFn: func(c manager.Config) any {
return c.Konnect.ControlPlaneID
},
ExpectedValue: "5ef731c0-6081-49d6-b3ec-d4f85e58b956",
},
},
}

for flag, flagTestCases := range testCasesGroupedByFlag {
Expand Down Expand Up @@ -188,7 +207,7 @@ func TestConfigValidate(t *testing.T) {
KongAdminSvc: mo.Some(k8stypes.NamespacedName{Name: "admin-svc", Namespace: "ns"}),
Konnect: adminapi.KonnectConfig{
ConfigSynchronizationEnabled: true,
RuntimeGroupID: "fbd3036f-0f1c-4e98-b71c-d4cd61213f90",
ControlPlaneID: "fbd3036f-0f1c-4e98-b71c-d4cd61213f90",
Address: "https://us.kic.api.konghq.tech",
TLSClient: adminapi.TLSClientConfig{
// We do not set valid cert or key, and it's still considered valid as at this level we only care
Expand Down Expand Up @@ -244,7 +263,7 @@ func TestConfigValidate(t *testing.T) {

t.Run("enabled with no runtime group is rejected", func(t *testing.T) {
c := validEnabled()
c.Konnect.RuntimeGroupID = ""
c.Konnect.ControlPlaneID = ""
require.ErrorContains(t, c.Validate(), "runtime group not specified")
czeslavo marked this conversation as resolved.
Show resolved Hide resolved
})

Expand Down
6 changes: 3 additions & 3 deletions test/e2e/konnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func createKonnectClientSecretAndConfigMap(ctx context.Context, t *testing.T, en
Name: "konnect-config",
},
Data: map[string]string{
"CONTROLLER_KONNECT_RUNTIME_GROUP_ID": rgID,
"CONTROLLER_KONNECT_CONTROL_PLANE_ID": rgID,
"CONTROLLER_KONNECT_ADDRESS": konnectRuntimeGroupAdminAPIBaseURL,
},
}, metav1.CreateOptions{})
Expand All @@ -336,7 +336,7 @@ func createKonnectAdminAPIClient(t *testing.T, rgID, cert, key string) *adminapi
t.Helper()

c, err := adminapi.NewKongClientForKonnectRuntimeGroup(adminapi.KonnectConfig{
RuntimeGroupID: rgID,
ControlPlaneID: rgID,
Address: konnectRuntimeGroupAdminAPIBaseURL,
TLSClient: adminapi.TLSClientConfig{
Cert: cert,
Expand All @@ -351,7 +351,7 @@ func createKonnectAdminAPIClient(t *testing.T, rgID, cert, key string) *adminapi
func createKonnectNodeClient(t *testing.T, rgID, cert, key string) *nodes.Client {
cfg := adminapi.KonnectConfig{
ConfigSynchronizationEnabled: true,
RuntimeGroupID: rgID,
ControlPlaneID: rgID,
Address: konnectRuntimeGroupAdminAPIBaseURL,
RefreshNodePeriod: konnect.MinRefreshNodePeriod,
TLSClient: adminapi.TLSClientConfig{
Expand Down