Introduce controller-runtime to handle dynamic clients. #441
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
How to categorize this PR?
/kind enhancement
/area logging
What this PR does / why we need it:
This PR replaces the legacy shared informer implementation with controller-runtime for managing dynamic Kubernetes clients. The controller-runtime framework provides a more modern, maintainable, and robust reconciliation pattern for watching Cluster resources and managing corresponding log forwarding clients. This change improves concurrent safety through atomic operations and proper synchronization primitives while maintaining the existing functionality for dynamic host path routing.
Code changes:
Controller Layer Refactoring:
pkg/cluster/clientsetand informer-based code generation packagespkg/controller/manager.goimplementing controller-runtime Manager with REST config handling (in-cluster and kubeconfig fallback)pkg/controller/reconciler.gowithClusterReconcilerimplementing the Reconcile pattern for Cluster resourcespkg/controller/test_helpers.gowithTestControllerManagerandTestClusterReconcilerfor unit testing without real Kubernetes clusterspkg/controller/controller.goto usesync.Mapfor concurrent-safe client storage andatomic.Boolfor stopped statepkg/controller/client.gowith improved locking patterns usingLoadOrStorefor race condition preventionPlugin Integration:
pkg/plugin/logging.goto accept a controller-runtimeControllerinterface instead of raw informercmd/fluent-bit-output-plugin/kubernetes_client.goandoutput_plugin.goto initialize controller-runtime managerinitControllerManagerwith proper context handlingTest Updates:
pkg/plugin/logging_test.goandtests/plugin/plugin_test.goto use fake controller-runtime clientsTestControllerManagerinstead of informersConfiguration Fixes:
pkg/config/config.go: corrected config key names (e.g.,sendlogstoshootwhenisinhhibernatingstate→sendlogstoshootwhenisinhibernatingstate)Minor Improvements:
pkg/client/dque_batch_processor.goAdditional context:
The migration to controller-runtime aligns with Kubernetes ecosystem best practices and provides better integration with other Gardener components. The new implementation maintains backward compatibility in terms of functionality while improving the internal architecture. All existing tests pass with the new implementation using fake clients.
Which issue(s) this PR fixes:
None specified
Special notes for your reviewer:
Release note:
📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!
PR Bot Information
Version:
1.17.53| 📖 Documentation | 🚨 Create Incident | 💬 Feedbackpull_request.openedanthropic--claude-4.5-sonnetf67b9230-05e1-11f1-8a98-aafc2cfffa4b