Firestore to Config Map Sync

Revision 2

Firestore to Config Map Sync
Sync Firestore feature flags to a Kubernetes ConfigMap in real time. A collection listener watches your `feature-flags` collection, a JS transform converts each document into a ConfigMap key-value pair, and the `configmap_patch` component writes directly to the cluster — no raw HTTP calls, no service account tokens for the K8s API. ## Firestore collection structure Create a collection called `feature-flags` (or any name — configurable in Ticker settings). Each document represents one feature flag: | Field | Type | Description | |---|---|---| | *(document ID)* | string | Used as the flag name, stored in ConfigMap as `flag-{docId}` | | `enabled` | boolean | Whether the flag is on or off | Example document (ID: `dark-mode`): ```json { "enabled": true } ``` This produces a ConfigMap key `flag-dark-mode` with value `{"enabled":true}`. You can add more fields to your documents — edit the JS script to include them in the serialized value. ### Quick start: seed the collection ```bash export PROJECT=YOUR_PROJECT gcloud firestore documents create \ --project=$PROJECT --database="(default)" \ --collection=feature-flags --document=dark-mode \ --field-data='{"enabled": true}' gcloud firestore documents create \ --project=$PROJECT --database="(default)" \ --collection=feature-flags --document=new-checkout \ --field-data='{"enabled": false}' gcloud firestore documents create \ --project=$PROJECT --database="(default)" \ --collection=feature-flags --document=ai-suggestions \ --field-data='{"enabled": true}' ``` Or create them manually in the [Firebase Console](https://console.firebase.google.com) under Firestore > `feature-flags`. ## How it works 1. **Ticker** starts the flow and carries all operational config (namespace, ConfigMap name, Slack credentials, Firestore collection) as context. 2. **Firestore Listen Collection** opens a real-time snapshot listener on the configured collection. Every add, modify, or remove fires a change event. 3. **JS Eval** transforms each change into a ConfigMap operation: computes the key (`flag-{docId}`), JSON-encodes the value, and picks `set` or `remove`. 4. **ConfigMap Patch** writes the key directly to the target ConfigMap using the in-cluster K8s client. 5. **Router** checks `slack_enabled` from the Ticker context. If true, routes to Slack Send; if false, drops to default (no-op). 6. **Slack Send** posts a notification with the ConfigMap result message. ## Setup 1. Install this solution. 2. Create the target ConfigMap in your cluster:\n ```bash\n kubectl create configmap feature-flags -n \n ``` 3. Open the Ticker settings and fill in: `namespace`, `config_map_name`, `collection`, and paste your Google service account JSON into `credentials`. 4. (Optional) To enable Slack notifications, set `slack_enabled` to true and fill in `slack_token` and `slack_channel`. 5. Start the Ticker. The Firestore listener connects and begins streaming changes. 6. Add or modify a document in your Firestore collection — the ConfigMap updates within seconds. ## Knobs to turn - **Collection name**: Change `collection` in the Ticker context to listen to a different Firestore collection. - **ConfigMap target**: Change `namespace` and `config_map_name` to write to any ConfigMap in any namespace the module has RBAC for. - **Flag value format**: Edit the JS script to change how flag documents are serialized into ConfigMap string values. - **Slack notifications**: Toggle `slack_enabled` in Ticker context to turn Slack on/off without rewiring the flow.
Modules
Flows
7
Nodes
1
Pages
3
Widgets
0
Installs

Dashboard Preview