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

feat: add FillIDs feature gate #4075

Merged
merged 2 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .github/workflows/_integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ jobs:
- name: dbless-combined-services
test: dbless
feature_gates: "GatewayAlpha=true,CombinedServices=true"
- name: dbless-fill-ids
test: dbless
feature_gates: "GatewayAlpha=true,FillIDs=true"
- name: postgres-fill-ids
test: postgres
feature_gates: "GatewayAlpha=true,FillIDs=true"
czeslavo marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: Kong/kong-license@master
Expand Down
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,23 @@ Adding a new version? You'll need three changes:
[#3832](https:/Kong/kubernetes-ingress-controller/pull/3832)
- Added license agent for Konnect-managed instances.
[#3883](https:/Kong/kubernetes-ingress-controller/pull/3883)
- `Service`, `Route` and `Consumer` Kong entities now get assigned deterministic
IDs based on their unique properties (name, username, etc.) instead of random
UUIDs.
- `Service`, `Route`, and `Consumer` Kong entities now can get assigned
deterministic IDs based on their unique properties (name, username, etc.)
instead of random UUIDs. To enable this feature, set `FillIDs` feature gate
to `true`.
It's going to be useful in cases where stable IDs are needed across multiple
Kong Gateways managed by KIC (e.g. for the integration with Konnect and
reporting metrics that later can be aggregated across multiple instances based
on the entity's ID).
When `FillIDs` will be enabled, the controller will re-create all the existing
entities (Services, Routes, and Consumers) with the new IDs assigned. That can
potentially lead to temporary downtime between the deletion of the old entities
and the creation of the new ones.
Users should be cautious about enabling the feature if their existing DB-backed
setup consists of a huge amount of entities for which the recreation can take
significant time.
[#3933](https:/Kong/kubernetes-ingress-controller/pull/3933)
[#4075](https:/Kong/kubernetes-ingress-controller/pull/4075)
- Added translator to translate ingresses under `networking.k8s.io/v1` to
expression based Kong routes. The translator is enabled when feature gate
`ExpressionRoutes` is turned on and the managed Kong gateway runs in router
Expand Down
1 change: 1 addition & 0 deletions FEATURE_GATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Features that reach GA and over time become stable will be removed from this tab
| GatewayAlpha | `false` | Alpha | 2.6.0 | TBD |
| ExpressionRoutes | `false` | Alpha | 2.10.0 | TBD |
| CombinedServices | `false` | Alpha | 2.10.0 | TBD |
| FillIDs | `false` | Alpha | 2.10.0 | 3.0.0 |

**NOTE**: The `Gateway` feature gate refers to [Gateway
API](https:/kubernetes-sigs/gateway-api) APIs which are in
Expand Down
11 changes: 9 additions & 2 deletions internal/dataplane/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ type FeatureFlags struct {
// CombinedServices enables parser to create a single Kong Service when a Kubernetes Service is referenced
// by multiple Ingresses. This is effective only when EnableCombinedServiceRoutes is enabled.
CombinedServices bool

// FillIDs enables the parser to fill in the IDs fields of Kong entities - Services, Routes, and Consumers - based
// on their names. It ensures that IDs remain stable across restarts of the controller.
FillIDs bool
}

func NewFeatureFlags(
Expand All @@ -93,6 +97,7 @@ func NewFeatureFlags(
RegexPathPrefix: kongVersion.MajorMinorOnly().GTE(versions.ExplicitRegexPathVersionCutoff),
ExpressionRoutes: expressionRoutesEnabled,
CombinedServices: combinedRoutesEnabled && featureGates.Enabled(featuregates.CombinedServicesFeature),
FillIDs: featureGates.Enabled(featuregates.FillIDsFeature),
}
}

Expand Down Expand Up @@ -233,8 +238,10 @@ func (p *Parser) BuildKongConfig() KongConfigBuildingResult {
result.Licenses = append(result.Licenses, p.licenseGetter.GetLicense())
}

// generate IDs for Kong entities
result.FillIDs(p.logger)
if p.featureFlags.FillIDs {
// generate IDs for Kong entities
result.FillIDs(p.logger)
}

return KongConfigBuildingResult{
KongState: &result,
Expand Down
13 changes: 12 additions & 1 deletion internal/dataplane/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5321,6 +5321,15 @@ func TestNewFeatureFlags(t *testing.T) {
CombinedServices: false,
},
},
{
name: "fill ids enabled",
featureGates: map[string]bool{
featuregates.FillIDsFeature: true,
},
expectedFeatureFlags: FeatureFlags{
FillIDs: true,
},
},
}

for _, tc := range testCases {
Expand All @@ -5341,7 +5350,9 @@ func TestNewFeatureFlags(t *testing.T) {
}

func mustNewParser(t *testing.T, storer store.Storer) *Parser {
p, err := NewParser(logrus.New(), storer, FeatureFlags{})
p, err := NewParser(logrus.New(), storer, FeatureFlags{
FillIDs: true, // We'll assume this is true for all tests.
})
require.NoError(t, err)
return p
}
5 changes: 5 additions & 0 deletions internal/manager/featuregates/feature_gates.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const (
// a Kubernetes Service is referenced by multiple netv1.Ingresses. It's effective only when CombinedRoutesFeature is enabled.
CombinedServicesFeature = "CombinedServices"

// FillIDsFeature is the name of the feature-gate that makes KIC fill in the ID fields of Kong entities (Services,
// Routes, and Consumers). It ensures that IDs remain stable across restarts of the controller.
FillIDsFeature = "FillIDs"

// DocsURL provides a link to the documentation for feature gates in the KIC repository.
DocsURL = "https:/Kong/kubernetes-ingress-controller/blob/main/FEATURE_GATES.md"
)
Expand Down Expand Up @@ -78,5 +82,6 @@ func GetFeatureGatesDefaults() map[string]bool {
CombinedRoutesFeature: true,
ExpressionRoutesFeature: false,
CombinedServicesFeature: false,
FillIDsFeature: false,
}
}