-
Notifications
You must be signed in to change notification settings - Fork 46
docs : align integration docs with current code #1060
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,10 @@ The `cac_redis_module` extends Redis with custom commands that allow clients to | |
|
|
||
| ## Features | ||
|
|
||
| - **Context-Aware Configuration**: Resolve configurations based on dynamic context conditions using JSONLogic | ||
| - **Context-Aware Configuration**: Resolve configurations based on dynamic context conditions using Superposition's JSONLogic-compatible evaluator | ||
| - **Redis Integration**: Access configuration resolution through Redis commands | ||
| - **Real-time Configuration**: Load and evaluate configurations from local JSON files | ||
| - **Multiple Merge Strategies**: Support for MERGE and REPLACE strategies when applying overrides | ||
| - **MERGE Resolution**: `CAC.EVAL` applies selected overrides with the `MERGE` strategy. `REPLACE` exists in the internal evaluator, but is not exposed by the Redis command. | ||
| - **Error Handling**: Comprehensive error reporting with timestamps and detailed messages | ||
|
|
||
| ## Architecture | ||
|
|
@@ -38,12 +38,14 @@ git clone https://github.com/juspay/superposition.git | |
| cd superposition/examples/cac_redis_module | ||
| ``` | ||
|
|
||
| 2. Build the Redis module: | ||
| 2. As checked in today, this example is under the repository workspace but is not listed in the root `workspace.members`. Before running Cargo commands from this directory, either add `examples/cac_redis_module` to the root workspace members or make the example an independent workspace by adding an empty `[workspace]` table to `examples/cac_redis_module/Cargo.toml`. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets drop the |
||
|
|
||
| 3. Build the Redis module: | ||
| ```bash | ||
| cargo build --release | ||
| ``` | ||
|
|
||
| 3. The compiled module will be available at `target/release/libredis_module_cac.so` (Linux) or `target/release/libredis_module_cac.dylib` (macOS). | ||
| 4. The compiled module is emitted to Cargo's target directory. In a root workspace build, that is typically `<repo>/target/release/libredis_module_cac.so` on Linux or `<repo>/target/release/libredis_module_cac.dylib` on macOS. In a standalone example workspace, the same files are under `target/release/` in the example directory. | ||
|
|
||
| ### Loading the Module | ||
|
|
||
|
|
@@ -223,7 +225,7 @@ The module provides detailed error messages for various scenarios: | |
| ## Performance Considerations | ||
|
|
||
| - **File I/O**: Configuration is loaded from disk on each evaluation. For production use, consider caching mechanisms | ||
| - **JSON Parsing**: JSONLogic evaluation is performed for each context condition | ||
| - **Condition Evaluation**: The Superposition logic helper evaluates each context condition | ||
| - **Memory Usage**: Module keeps minimal state; most data is processed per request | ||
|
|
||
| ## Development | ||
|
|
@@ -234,8 +236,7 @@ The module uses these key dependencies: | |
|
|
||
| - `redis-module`: Redis module SDK for Rust | ||
| - `serde_json`: JSON serialization/deserialization | ||
| - `jsonlogic`: JSONLogic rule evaluation engine | ||
| - `superposition_types`: Superposition's type definitions | ||
| - `superposition_types`: Superposition's shared types and condition evaluation helpers | ||
|
|
||
| ### Extending the Module | ||
|
|
||
|
|
@@ -304,8 +305,8 @@ redis-cli> CAC.EVAL '{"test": "value"}' | |
|
|
||
| - The module reads configuration files from the local filesystem | ||
| - No authentication is performed on Redis commands (use Redis AUTH if needed) | ||
| - JSONLogic evaluation should be considered when exposing user-controllable context data | ||
| - Condition evaluation should be considered when exposing user-controllable context data | ||
|
|
||
| ## Source Code | ||
|
|
||
| The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/cac_redis_module). | ||
| The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/cac_redis_module). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # Kubernetes Staggered Releaser (Mayday) | ||
|
|
||
| A Kubernetes deployment automation tool that leverages Superposition's experimentation features to perform safe, gradual rollouts with automatic traffic management and rollback capabilities. | ||
| A Kubernetes deployment automation example that leverages Superposition's experimentation events to perform gradual rollouts with NGINX Ingress traffic management. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep the older description? I don't think we use nginx here |
||
|
|
||
| ## Overview | ||
|
|
||
|
|
@@ -13,7 +13,7 @@ The `k8s-staggered-releaser` (internally named "Mayday") is a webhook-driven dep | |
| - **Automatic Resource Management**: Creates and manages Kubernetes Deployments, Services, and Ingresses | ||
| - **Multi-Namespace Support**: Deploy to different Kubernetes namespaces based on context | ||
| - **Traffic Management**: Uses NGINX Ingress Controller for weighted traffic distribution | ||
| - **Rollback Capability**: Automatic cleanup and rollback when experiments conclude | ||
| - **Conclusion Cleanup**: Updates the main Service for the chosen variant and deletes experimental Services and Ingresses when experiments conclude. Deployment deletion is not implemented in the checked-in example. | ||
| - **Configuration Integration**: Fetches deployment configurations from Superposition | ||
|
|
||
| ## Architecture | ||
|
|
@@ -31,7 +31,7 @@ The `k8s-staggered-releaser` (internally named "Mayday") is a webhook-driven dep | |
|
|
||
| 1. **Experiment Started**: Creates new Deployment, Service, and Ingress resources | ||
| 2. **Experiment In Progress**: Updates traffic weights for gradual rollout | ||
| 3. **Experiment Concluded**: Promotes winning variant and cleans up resources | ||
| 3. **Experiment Concluded**: Promotes the winning variant by updating the main Service, then deletes experimental Services and Ingresses | ||
|
|
||
| ## Installation | ||
|
|
||
|
|
@@ -56,12 +56,14 @@ pub const K8S_API_SERVER: &str = "https://your-k8s-api-server:6443"; | |
| pub const TOKEN: &str = "your-k8s-api-token"; | ||
| ``` | ||
|
|
||
| 3. Build the application: | ||
| 3. As checked in today, this example is under the repository workspace but is not listed in the root `workspace.members`. Before running Cargo commands from this directory, either add `examples/k8s-staggered-releaser` to the root workspace members or make the example an independent workspace by adding an empty `[workspace]` table to `examples/k8s-staggered-releaser/Cargo.toml`. | ||
|
|
||
| 4. Build the application: | ||
| ```bash | ||
| cargo build --release | ||
| ``` | ||
|
|
||
| 4. Run the webhook server: | ||
| 5. Run the webhook server: | ||
| ```bash | ||
| cargo run | ||
| ``` | ||
|
|
@@ -70,13 +72,13 @@ The server will start on `127.0.0.1:8090` and listen for webhook events at `/hi` | |
|
|
||
| ## Configuration | ||
|
|
||
| ### Environment Variables | ||
| ### Source Constants | ||
|
|
||
| You can configure the following constants in `src/utils.rs`: | ||
| The checked-in example reads these values as constants in `src/utils.rs`, not as environment variables: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really useful as documentation, the section can just be removed |
||
|
|
||
| - `K8S_API_SERVER`: Kubernetes API server URL | ||
| - `TOKEN`: Kubernetes API authentication token | ||
| - `NAMESPACE`: Default namespace for deployments | ||
| - `NAMESPACE`: Declared as `"default"`, but the webhook handlers derive the active namespace from `payload.context` through `get_namespace` | ||
|
|
||
| ### Superposition Integration | ||
|
|
||
|
|
@@ -186,17 +188,17 @@ Triggered when an experiment ends with a chosen variant: | |
| **Actions Performed:** | ||
| - Updates main service to point to winning variant deployment | ||
| - Removes experimental Ingress resources | ||
| - Cleans up unused Services and Deployments | ||
| - Deletes experimental Ingresses and Services. Deployment cleanup is not implemented. | ||
|
|
||
| ### Configuration Resolution | ||
|
|
||
| The system fetches deployment configurations from Superposition using the `/config/resolve` endpoint: | ||
|
|
||
| ``` | ||
| GET /config/resolve?namespace={namespace}&variantIds={variant_id} | ||
| GET http://localhost:8080/config/resolve?dimension[namespace]={namespace}&dimension[variantIds]={variant_id} | ||
| Headers: | ||
| x-org-id: localorg | ||
| x-tenant: {service_name} | ||
| x-tenant: {workspace_id} | ||
| ``` | ||
|
Comment on lines
197
to
202
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add language specifier to fenced code block. The code block for the Configuration Resolution request example is missing a language specifier, which violates markdown linting rules (MD040). The content is a plaintext HTTP request, so it should use a language identifier like 🔧 Proposed fix-```
+```bash
GET http://localhost:8080/config/resolve?dimension[namespace]={namespace}&dimension[variantIds]={variant_id}
Headers:
x-org-id: localorg
x-tenant: {workspace_id}
-```
+```🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 197-197: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| Expected configuration format: | ||
|
|
@@ -235,11 +237,13 @@ metadata: | |
| nginx.ingress.kubernetes.io/canary: "true" | ||
| nginx.ingress.kubernetes.io/canary-weight: "25" | ||
| spec: | ||
| ingressClassName: nginx | ||
| rules: | ||
| - host: nginxservice.mumbai | ||
| http: | ||
| paths: | ||
| - path: / | ||
| pathType: Prefix | ||
| backend: | ||
| service: | ||
| name: nginxservice-service-variant-123 | ||
|
|
@@ -344,12 +348,7 @@ Common error scenarios and troubleshooting: | |
|
|
||
| ### Health Checks | ||
|
|
||
| Monitor the webhook endpoint: | ||
|
|
||
| ```bash | ||
| # Basic health check | ||
| curl http://127.0.0.1:8090/hi | ||
| ``` | ||
| There is no separate health endpoint. The `/hi` route is a GET webhook receiver that expects a JSON request body matching the Superposition event shape. | ||
|
|
||
| ## Advanced Configuration | ||
|
|
||
|
|
@@ -364,6 +363,8 @@ let app_state = Data::new(AppState { | |
| }); | ||
| ``` | ||
|
|
||
| The checked-in handler stores this `AppState`, but does not currently validate webhook namespaces or tenants against those lists. | ||
|
|
||
| ### Custom Resource Templates | ||
|
|
||
| Modify resource generation in respective modules: | ||
|
|
@@ -451,4 +452,4 @@ When contributing to this example: | |
|
|
||
| ## Source Code | ||
|
|
||
| The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/k8s-staggered-releaser). | ||
| The complete source code for this example is available in the [Superposition repository](https://github.com/juspay/superposition/tree/main/examples/k8s-staggered-releaser). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,7 +124,7 @@ The following matrix contains the languages in which the above client libraries | |
| | Rust | [](https://crates.io/crates/superposition_sdk) | [](https://crates.io/crates/superposition_provider) | | ||
| | Javascript | [](https://www.npmjs.com/package/superposition-sdk) | [](https://www.npmjs.com/package/superposition-provider) | | ||
| | Python | [](https://pypi.org/project/superposition-sdk/) | [](https://pypi.org/project/superposition-provider/) | | ||
| | Java | [](https://central.sonatype.com/artifact/io.juspay.superposition/sdk) | [](https://central.sonatype.com/artifact/io.juspay.superposition/openfeature-provider)| | ||
| | Java | [](https://central.sonatype.com/artifact/io.juspay.superposition/sdk) | [`io.juspay.superposition.openfeature:superposition-provider`](./providers/openfeature/java.md) | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we revert this? |
||
| | Haskell |  |  | | ||
| | Go | TBD | TBD | | ||
|
|
||
|
|
@@ -160,4 +160,3 @@ Superposition comes as a shot in the arm for any application that needs safe and | |
|
|
||
| ## Email us | ||
| * [superposition@juspay.in](mailto:superposition@juspay.in) | ||
|
|
||
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 didn't understand the reason for this change