-
Notifications
You must be signed in to change notification settings - Fork 7
K8s-less mode #1164
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
K8s-less mode #1164
Conversation
af51bc2 to
7f3ab83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces k8s-less mode to enable dataplane operation without Kubernetes infrastructure, facilitating early testing during feature development. The implementation includes a procedural macro for generating sample configurations, utilities for creating sample CRD files, and a file-watching mechanism that detects configuration changes in a designated directory.
Key changes:
- Added
k8s-sample-derivecrate withSamplederive macro for automatic sample data generation - Implemented k8s-less mode via
--config-dircommand-line argument with inotify-based file watching - Created
k8s-sample-crdscrate to generate JSON/YAML sample configuration templates
Reviewed changes
Copilot reviewed 23 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| mgmt/src/processor/mod.rs | Added k8s_less_client module |
| mgmt/src/processor/launch.rs | Integrated k8s-less mode into management startup flow |
| mgmt/src/processor/k8s_less_client.rs | Implemented K8sLess client for file-based configuration |
| mgmt/Cargo.toml | Added k8s-less dependency |
| k8s-sample-derive/src/lib.rs | Implemented Sample derive macro for generating sample data |
| k8s-sample-derive/Cargo.toml | Configured procedural macro crate |
| k8s-sample-crds/src/lib.rs | Added test verifying JSON/YAML sample equivalence |
| k8s-sample-crds/generated-samples/sample.yaml | Generated sample YAML configuration template |
| k8s-sample-crds/generated-samples/sample.json | Generated sample JSON configuration template |
| k8s-sample-crds/build.rs | Build script for automatic sample generation |
| k8s-sample-crds/Cargo.toml | Configured sample generation crate |
| k8s-less/src/local.rs | Implemented inotify-based directory watching and CRD deserialization |
| k8s-less/src/lib.rs | Exposed kubeless_watch_gateway_agent_crd function |
| k8s-less/Cargo.toml | Configured k8s-less crate dependencies |
| k8s-intf/src/utils.rs | Added utilities for loading CRDs from JSON/YAML files |
| k8s-intf/src/samplegen/sample.rs | Defined Sample trait and implementations for primitive types |
| k8s-intf/src/samplegen/mod.rs | Implemented sample file generation logic |
| k8s-intf/src/lib.rs | Exposed samplegen and utils modules |
| k8s-intf/build.rs | Updated build script to derive Sample trait via kopium |
| k8s-intf/Cargo.toml | Added k8s-sample-derive and serde_yaml_ng dependencies |
| dataplane/src/main.rs | Passed config_dir parameter to management initialization |
| args/src/lib.rs | Added config_dir command-line argument and updated configuration structures |
| Cargo.toml | Added k8s-less, k8s-sample-crds, k8s-sample-derive crates and inotify dependency |
7f3ab83 to
2b2531c
Compare
mvachhar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the name kubeless rather than k8s-less but not worth the fix. Still thinking about the Sample stuff to see if there is a nicer way to do that. Also, when do all the FIXME's get removed?
|
Oh, it looks like something isn't right with the package setup too causing uncommitted changes during build. |
|
I think the Sample stuff here is a bit controversial and needs discussion. Can we split this out from this PR that adds the inotify stuff? I think it will be straight forward to merge that and remove gRPC while we discuss what is going on with Sample. |
I can try to change it. The FIXME's have to be manually removed. That's the point. The Sample trait is to produce sample yaml/json files for testing. It's a template so that we can manually create configs. |
0a33e9e to
02b1eea
Compare
Signed-off-by: Fredi Raspall <[email protected]>
Adds a new crate to support kubeless mode (k8s-less), where dataplane learns its configuration by monitoring changes in files inside a directory (using inotify) that contain the gateway spec in yaml or json. Files that change in (or get added to) the watched directory get read and their contents (yaml or json) deserialized into a crd spec. From that spec, a GatewayAgent object (representing the main CRD) is built and passed to a user-provided callback. This crate attempts to mimic k8s-intf and deals only with: - the watching of files in a directory using inotify - the deserialization of those files into the GatewayAgent type. It does not attempt to populate/build any of the configuration types in crate dataplane-config. As this mode of operation may be used only for testing or development, we implement it outside of the k8s-intf crate. Signed-off-by: Fredi Raspall <[email protected]>
Adds --config-dir cmd line option to specify the directory in k8s- less mode and augments the ConfigServerSection to include it. Signed-off-by: Fredi Raspall <[email protected]>
Add a k8s-less client that watches the config directory and uses the config client to request the config processor to apply a new config. Signed-off-by: Fredi Raspall <[email protected]>
02b1eea to
0678410
Compare
Add utility functions to save objects in yaml and json. Signed-off-by: Fredi Raspall <[email protected]>
Move the code to create a GatewayAgentStatus object out of K8sClient::update_gateway_status() method into a standalone function so that the same code can be used in kubeless mode. Signed-off-by: Fredi Raspall <[email protected]>
Augments the k8s-less client to write status in yaml and json each time a configuration is successfully applied. In this implementation, the state is serialized in two files: - gwstatus.json - gwstatus.yaml within a "state" directory created in the watched directory. This is to avoid needing to add another cmd line option for the directory to store the status files, which seems unnecessary at this point. Signed-off-by: Fredi Raspall <[email protected]>
mvachhar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good enough as it is for test and dev.
|
#1165 which is on top of this PR passes all tests so the upgrade failure is very likely spurious. If the upgrade fails again, just close and reopen this PR and add to the merge queue. |
Pull request was closed
Support for kubeless mode.