From e317fbe389fc7cf3153c0e20d1bfa632703d3e22 Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Wed, 13 Oct 2021 10:50:08 +0200 Subject: [PATCH] Promote CachedRuntimeClients feature gate to beta --- docs/deployment/feature_gates.md | 3 ++- docs/development/kubernetes-clients.md | 9 +++++---- pkg/client/kubernetes/client.go | 7 ++++--- pkg/controllermanager/features/features.go | 2 +- pkg/features/features.go | 3 ++- pkg/gardenlet/features/features.go | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/deployment/feature_gates.md b/docs/deployment/feature_gates.md index 50d6720d3f25..3bef0b43dd40 100644 --- a/docs/deployment/feature_gates.md +++ b/docs/deployment/feature_gates.md @@ -27,7 +27,8 @@ The following tables are a summary of the feature gates that you can set on diff | ManagedIstio | `true` | `Beta` | `1.19` | | | APIServerSNI | `false` | `Alpha` | `1.7` | `1.18` | | APIServerSNI | `true` | `Beta` | `1.19` | | -| CachedRuntimeClients | `false` | `Alpha` | `1.7` | | +| CachedRuntimeClients | `false` | `Alpha` | `1.7` | `1.33` | +| CachedRuntimeClients | `true` | `Beta` | `1.34` | | | SeedChange | `false` | `Alpha` | `1.12` | | | SeedKubeScheduler | `false` | `Alpha` | `1.15` | | | ReversedVPN | `false` | `Alpha` | `1.22` | | diff --git a/docs/development/kubernetes-clients.md b/docs/development/kubernetes-clients.md index c5b0ea929db2..a0b5c0393e1a 100644 --- a/docs/development/kubernetes-clients.md +++ b/docs/development/kubernetes-clients.md @@ -185,10 +185,11 @@ This means, that if you read the same object from different cache implementation By default, the `client.Client` created by a controller-runtime `Manager` is a `DelegatingClient`. It delegates `Get` and `List` calls to a `Cache` and all other calls to a client, that talks directly to the API server. Exceptions are requests with `*unstructured.Unstructured` objects and object kinds that were configured to be excluded from the cache in the `DelegatingClient`. -> ℹ️ Currently, the controller-runtime client contained in Gardener's client collection (`kubernetes.Interface.Client()`) is not cached and does not use the cache contained in the client set (`kubernetes.Interface.Cache()`). This means, the client always reads directly from the API server, but you can intentionally read from the cache if desired. -> -> If the `CachedRuntimeClients` feature gate is enabled, `Client()` returns a `DelegatingClient` that uses the cache returned from `Cache()` under the hood. This means, all `Client()` usages should be ready for cached clients and should be able to cater with stale cache reads. -> See [gardener/gardener#2822](https://github.com/gardener/gardener/issues/2822) for details on the graduation progress. +> ℹ️ +> If the `CachedRuntimeClients` feature gate is enabled (enabled by default starting from `v1.34`), `kubernetes.Interface.Client()` returns a `DelegatingClient` that uses the cache returned from `kubernetes.Interface.Cache()` under the hood. This means, all `Client()` usages need to be ready for cached clients and should be able to cater with stale cache reads. +> See [gardener/gardener#2822](https://github.com/gardener/gardener/issues/2822) for details on the graduation progress to beta. +> +> If the feature gate is explicitly disabled, the controller-runtime client (`kubernetes.Interface.Client()`) is not cached and does not use the cache contained in the client set (`kubernetes.Interface.Cache()`). This means, the client always reads directly from the API server, but you can intentionally read from the cache if desired. _Important characteristics of cached controller-runtime clients:_ diff --git a/pkg/client/kubernetes/client.go b/pkg/client/kubernetes/client.go index 934f2629b829..ad4d8be92483 100644 --- a/pkg/client/kubernetes/client.go +++ b/pkg/client/kubernetes/client.go @@ -40,9 +40,10 @@ import ( ) var ( - // UseCachedRuntimeClients is a flag for enabling cached controller-runtime clients (defaults to false). - // If enabled, the client returned by Interface.Client() will be backed by a cache, otherwise it will talk directly - // to the API server. + // UseCachedRuntimeClients is a flag for enabling cached controller-runtime clients. The CachedRuntimeClients feature + // gate (enabled by default sinde v1.34) causes this flag to be set to true. + // If enabled, the client returned by Interface.Client() will be backed by Interface.Cache(), otherwise it will talk + // directly to the API server. UseCachedRuntimeClients = false ) diff --git a/pkg/controllermanager/features/features.go b/pkg/controllermanager/features/features.go index 92b3079cd7ac..d037dabc6c3d 100644 --- a/pkg/controllermanager/features/features.go +++ b/pkg/controllermanager/features/features.go @@ -25,7 +25,7 @@ var ( // FeatureGate is a shared global FeatureGate for Gardener Controller Manager flags. FeatureGate = featuregate.NewFeatureGate() featureGates = map[featuregate.Feature]featuregate.FeatureSpec{ - features.CachedRuntimeClients: {Default: false, PreRelease: featuregate.Alpha}, + features.CachedRuntimeClients: {Default: true, PreRelease: featuregate.Beta}, features.UseDNSRecords: {Default: false, PreRelease: featuregate.Alpha}, features.RotateSSHKeypairOnMaintenance: {Default: false, PreRelease: featuregate.Alpha}, } diff --git a/pkg/features/features.go b/pkg/features/features.go index 8f835fb4168b..0f506ca674f0 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -61,8 +61,9 @@ const ( // CachedRuntimeClients enables a cache in the controller-runtime clients, that Gardener uses. // If disabled all controller-runtime clients will directly talk to the API server instead of relying on a cache. - // owner @tim-ebert + // owner @timebertt // alpha: v1.7.0 + // beta: v1.34.0 CachedRuntimeClients featuregate.Feature = "CachedRuntimeClients" // SeedChange enables updating the `spec.seedName` field during shoot validation from a non-empty value diff --git a/pkg/gardenlet/features/features.go b/pkg/gardenlet/features/features.go index 3047a5d6d5dc..04619f2504f4 100644 --- a/pkg/gardenlet/features/features.go +++ b/pkg/gardenlet/features/features.go @@ -30,7 +30,7 @@ var ( features.HVPAForShootedSeed: {Default: false, PreRelease: featuregate.Alpha}, features.ManagedIstio: {Default: true, PreRelease: featuregate.Beta}, features.APIServerSNI: {Default: true, PreRelease: featuregate.Beta}, - features.CachedRuntimeClients: {Default: false, PreRelease: featuregate.Alpha}, + features.CachedRuntimeClients: {Default: true, PreRelease: featuregate.Beta}, features.SeedKubeScheduler: {Default: false, PreRelease: featuregate.Alpha}, features.ReversedVPN: {Default: false, PreRelease: featuregate.Alpha}, features.UseDNSRecords: {Default: false, PreRelease: featuregate.Alpha},