|
| 1 | +# Router Configuration Migration Guide |
| 2 | + |
| 3 | +This document describes how the router configuration from `deploy/router/values.yaml` was migrated to operator-managed Supergraph CRDs. |
| 4 | + |
| 5 | +## Migration Summary |
| 6 | + |
| 7 | +All router configuration has been moved from Helm values (`deploy/router/values.yaml`) into the Supergraph CRD specifications: |
| 8 | +- `deploy/operator-resources/supergraph-dev.yaml` (dev environment) |
| 9 | +- `deploy/operator-resources/supergraph-prod.yaml` (prod environment) |
| 10 | + |
| 11 | +## Configuration Mapping |
| 12 | + |
| 13 | +### Core Router Settings (Both Dev and Prod) |
| 14 | + |
| 15 | +| Previous Location | New Location | Value | |
| 16 | +|-------------------|--------------|-------| |
| 17 | +| `router.configuration.health_check` | `spec.podTemplate.router.configuration.health_check` | `listen: 0.0.0.0:8080` | |
| 18 | +| `router.configuration.sandbox` | `spec.podTemplate.router.configuration.sandbox` | `enabled: true` | |
| 19 | +| `router.configuration.homepage` | `spec.podTemplate.router.configuration.homepage` | `enabled: false` | |
| 20 | +| `router.configuration.supergraph` | `spec.podTemplate.router.configuration.supergraph` | `introspection: true` | |
| 21 | +| `router.configuration.include_subgraph_errors` | `spec.podTemplate.router.configuration.include_subgraph_errors` | `all: true` | |
| 22 | +| `router.configuration.plugins` | `spec.podTemplate.router.configuration.plugins` | `experimental.expose_query_plan: true` | |
| 23 | + |
| 24 | +### Authentication & Authorization |
| 25 | + |
| 26 | +- **JWKS Authentication**: Points to `http://graphql.users.svc.cluster.local:4001/.well-known/jwks.json` |
| 27 | +- **Authorization Preview Directives**: Enabled for all subgraphs |
| 28 | + |
| 29 | +### Coprocessor Configuration |
| 30 | + |
| 31 | +- **URL**: `http://coprocessor.coprocessor.svc.cluster.local:8081` |
| 32 | +- **Timeout**: 2s |
| 33 | +- **Router Request Headers**: Enabled |
| 34 | +- **Subgraph Request/Response Headers**: Enabled |
| 35 | + |
| 36 | +### Rhai Scripts |
| 37 | + |
| 38 | +Rhai scripts are handled via ConfigMap and volume mounts: |
| 39 | +- **Scripts Location**: `/dist/rhai` (mounted from ConfigMap) |
| 40 | +- **Main Script**: `main.rhai` |
| 41 | +- **Helper Scripts**: `client_id.rhai` |
| 42 | + |
| 43 | +The ConfigMap must be created separately: |
| 44 | +```bash |
| 45 | +kubectl create configmap rhai-config --from-file=deploy/router/rhai/ -n apollo |
| 46 | +``` |
| 47 | + |
| 48 | +### Prod-Only Configuration |
| 49 | + |
| 50 | +The following configurations are only present in `supergraph-prod.yaml`: |
| 51 | + |
| 52 | +#### Persisted Queries |
| 53 | + |
| 54 | +```yaml |
| 55 | +persisted_queries: |
| 56 | + enabled: true |
| 57 | + log_unknown: true |
| 58 | + safelist: |
| 59 | + enabled: false |
| 60 | + require_id: false |
| 61 | +``` |
| 62 | +
|
| 63 | +#### Telemetry |
| 64 | +
|
| 65 | +- **Apollo Field-Level Instrumentation**: Sampler 0.5 |
| 66 | +- **OTLP Tracing**: gRPC endpoint `http://collector.monitoring:4317` |
| 67 | +- **OTLP Metrics**: gRPC endpoint `http://collector.monitoring:4317` |
| 68 | +- **Service Name**: "router" |
| 69 | +- **Service Namespace**: "router" |
| 70 | + |
| 71 | +## How to Update Router Configuration |
| 72 | + |
| 73 | +To update router configuration without redeploying subgraphs: |
| 74 | + |
| 75 | +1. Edit the appropriate Supergraph CRD file: |
| 76 | + - Dev: `deploy/operator-resources/supergraph-dev.yaml` |
| 77 | + - Prod: `deploy/operator-resources/supergraph-prod.yaml` |
| 78 | + |
| 79 | +2. Update the `spec.podTemplate.router.configuration` section |
| 80 | + |
| 81 | +3. Apply the changes: |
| 82 | + ```bash |
| 83 | + kubectl apply -f deploy/operator-resources/supergraph-{dev|prod}.yaml |
| 84 | + ``` |
| 85 | + |
| 86 | +4. The operator will automatically trigger a router rollover with the new configuration |
| 87 | + |
| 88 | +## Resources |
| 89 | + |
| 90 | +Dev environment uses minimal resources: |
| 91 | +- CPU: 100m |
| 92 | +- Memory: 256Mi |
| 93 | +- Replicas: 1 |
| 94 | + |
| 95 | +Prod environment uses production-grade resources: |
| 96 | +- CPU: 500m |
| 97 | +- Memory: 512Mi |
| 98 | +- Replicas: 3 |
| 99 | + |
| 100 | +## Differences from Helm Chart |
| 101 | + |
| 102 | +The operator-managed approach differs from the Helm chart in several ways: |
| 103 | + |
| 104 | +1. **No Helm templates**: Configuration is defined in Kubernetes-native CRDs |
| 105 | +2. **Automatic rollover**: The operator handles rolling out changes to the router |
| 106 | +3. **Declarative**: All configuration is version-controlled in YAML files |
| 107 | +4. **Condition-based**: Can monitor router status via `kubectl get supergraph` |
| 108 | + |
| 109 | +## Troubleshooting |
| 110 | + |
| 111 | +### Router not picking up changes |
| 112 | + |
| 113 | +Check the Supergraph status: |
| 114 | +```bash |
| 115 | +kubectl describe supergraph reference-architecture-{dev|prod} -n apollo |
| 116 | +``` |
| 117 | + |
| 118 | +Look for: |
| 119 | +- `SchemaLoaded`: Should be `True` |
| 120 | +- `Progressing`: Shows deployment status |
| 121 | +- `Ready`: Should be `True` when fully deployed |
| 122 | + |
| 123 | +### Rhai scripts not working |
| 124 | + |
| 125 | +Verify the ConfigMap exists and is mounted: |
| 126 | +```bash |
| 127 | +kubectl get configmap rhai-config -n apollo |
| 128 | +kubectl describe pod <router-pod> -n apollo | grep rhai-volume |
| 129 | +``` |
| 130 | + |
| 131 | +### Coprocessor connection issues |
| 132 | + |
| 133 | +Ensure coprocessor is running and accessible: |
| 134 | +```bash |
| 135 | +kubectl get pods -n coprocessor |
| 136 | +kubectl get svc -n coprocessor |
| 137 | +``` |
| 138 | + |
| 139 | +## Current Configuration Status |
| 140 | + |
| 141 | +The Supergraph CRDs in this repository use a **simplified configuration** that does not include all the advanced router settings from the original Helm chart. This is because the current Apollo GraphOS Operator CRD does not support all configuration fields. |
| 142 | + |
| 143 | +### Supported Configuration |
| 144 | +- ✅ Replicas count |
| 145 | +- ✅ Router version |
| 146 | +- ✅ Resource limits/requests |
| 147 | +- ✅ Schema source (SupergraphSchema resource reference) |
| 148 | + |
| 149 | +### Not Currently Supported in Supergraph CRD |
| 150 | +- ❌ Custom router configuration (JWKS auth, coprocessor, CORS, etc.) |
| 151 | +- ❌ Rhai scripts via ConfigMap volumes |
| 152 | +- ❌ Custom ingress configuration |
| 153 | +- ❌ Service type customization |
| 154 | +- ❌ Telemetry exporters |
| 155 | +- ❌ Advanced authentication/authorization |
| 156 | + |
| 157 | +### Operator API Key Setup |
| 158 | + |
| 159 | +The operator requires an **Operator API key** (not a personal API key). To create one: |
| 160 | + |
| 161 | +1. Go to GraphOS Studio |
| 162 | +2. Navigate to your graph → Settings → API Keys |
| 163 | +3. Create a new API key with "Operator" role |
| 164 | +4. Update the `apollo-api-key` secret with the Operator API key: |
| 165 | + ```bash |
| 166 | + kubectl create secret generic apollo-api-key \ |
| 167 | + --from-literal="APOLLO_KEY=<your-operator-api-key>" \ |
| 168 | + -n apollo-operator \ |
| 169 | + --dry-run=client -o yaml | kubectl apply -f - |
| 170 | + ``` |
| 171 | + |
| 172 | +### TODO: Advanced Router Configuration |
| 173 | + |
| 174 | +The advanced router configuration (JWKS, coprocessor, Rhai scripts, telemetry, persisted queries) from the original `deploy/router/values.yaml` has not been migrated yet. This would need to be implemented either: |
| 175 | + |
| 176 | +1. Via router configuration YAML file in a ConfigMap (if supported) |
| 177 | +2. Through GraphOS Studio router configuration |
| 178 | +3. By extending the operator to support these fields |
| 179 | +4. By using a custom router deployment instead of the operator-managed one |
| 180 | + |
| 181 | +### Current Status |
| 182 | + |
| 183 | +- Graph is created ✅ |
| 184 | +- Dev and prod variants created ✅ |
| 185 | +- Subgraphs deployed and CRDs created ✅ |
| 186 | +- Operator API key needs to be set up ⚠️ |
| 187 | +- Advanced router configuration not yet migrated ⏳ |
| 188 | + |
0 commit comments