Skip to content

Commit cde2d2f

Browse files
committed
feat: implement decision-based routing with plugin architecture
Signed-off-by: bitliu <[email protected]>
1 parent eae6d3a commit cde2d2f

File tree

7 files changed

+57
-182
lines changed

7 files changed

+57
-182
lines changed

deploy/helm/semantic-router/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,40 @@ A Helm chart for deploying Semantic Router - an intelligent routing system for L
66

77
**Homepage:** <https://github.com/vllm-project/semantic-router>
88

9+
## CRD Management
10+
11+
This Helm chart includes Custom Resource Definitions (CRDs) in the `crds/` directory:
12+
- `vllm.ai_intelligentpools.yaml` - IntelligentPool CRD
13+
- `vllm.ai_intelligentroutes.yaml` - IntelligentRoute CRD
14+
15+
### Generating CRDs
16+
17+
CRDs are automatically generated from Go type definitions using `controller-gen`. To regenerate CRDs:
18+
19+
```bash
20+
# From the repository root
21+
make generate-crd
22+
```
23+
24+
This command will:
25+
1. Generate CRDs from `src/semantic-router/pkg/apis/vllm.ai/v1alpha1` types
26+
2. Output to `deploy/kubernetes/crds/`
27+
3. Copy to `deploy/helm/semantic-router/crds/` for Helm chart
28+
29+
### CRD Installation
30+
31+
CRDs in the `crds/` directory are automatically installed by Helm:
32+
- Installed **before** other resources during `helm install`
33+
- **Not managed** by Helm (no Helm labels/annotations)
34+
- **Not updated** during `helm upgrade` (must be updated manually)
35+
- **Not deleted** during `helm uninstall` (protects custom resources)
36+
37+
To manually update CRDs:
38+
39+
```bash
40+
kubectl apply -f deploy/helm/semantic-router/crds/
41+
```
42+
943
## Maintainers
1044

1145
| Name | Email | Url |

deploy/kubernetes/crds/examples/intelligentpool-example.yaml

Lines changed: 0 additions & 32 deletions
This file was deleted.

deploy/kubernetes/crds/examples/intelligentroute-example.yaml

Lines changed: 0 additions & 144 deletions
This file was deleted.

src/semantic-router/pkg/extproc/router.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,25 @@ var _ ext_proc.ExternalProcessorServer = (*OpenAIRouter)(nil)
3333

3434
// NewOpenAIRouter creates a new OpenAI API router instance
3535
func NewOpenAIRouter(configPath string) (*OpenAIRouter, error) {
36-
// Always parse fresh config for router construction (supports live reload)
37-
cfg, err := config.Parse(configPath)
38-
if err != nil {
39-
return nil, fmt.Errorf("failed to load config: %w", err)
36+
var cfg *config.RouterConfig
37+
var err error
38+
39+
// Check if we should use the global config (Kubernetes mode) or parse from file
40+
globalCfg := config.Get()
41+
if globalCfg != nil && globalCfg.ConfigSource == config.ConfigSourceKubernetes {
42+
// Use the global config that's managed by the Kubernetes controller
43+
cfg = globalCfg
44+
logging.Infof("Using Kubernetes-managed configuration")
45+
} else {
46+
// Parse fresh config from file for file-based configuration (supports live reload)
47+
cfg, err = config.Parse(configPath)
48+
if err != nil {
49+
return nil, fmt.Errorf("failed to load config: %w", err)
50+
}
51+
// Update global config reference for packages that rely on config.GetConfig()
52+
config.Replace(cfg)
53+
logging.Debugf("Parsed configuration from file: %s", configPath)
4054
}
41-
// Update global config reference for packages that rely on config.GetConfig()
42-
config.Replace(cfg)
4355

4456
// Load category mapping if classifier is enabled
4557
var categoryMapping *classification.CategoryMapping

tools/make/golang.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ install-controller-gen: ## Install controller-gen for code generation
4646
generate-crd: install-controller-gen ## Generate CRD manifests using controller-gen
4747
@echo "Generating CRD manifests..."
4848
@cd src/semantic-router && controller-gen crd:crdVersions=v1,allowDangerousTypes=true paths=./pkg/apis/vllm.ai/v1alpha1 output:crd:artifacts:config=../../deploy/kubernetes/crds
49+
@echo "Copying CRDs to Helm chart..."
50+
@mkdir -p deploy/helm/semantic-router/crds
51+
@cp deploy/kubernetes/crds/vllm.ai_intelligentpools.yaml deploy/helm/semantic-router/crds/
52+
@cp deploy/kubernetes/crds/vllm.ai_intelligentroutes.yaml deploy/helm/semantic-router/crds/
53+
@echo "✅ CRDs generated and copied to Helm chart"
4954

5055
generate-deepcopy: install-controller-gen ## Generate deepcopy methods using controller-gen
5156
@echo "Generating deepcopy methods..."

0 commit comments

Comments
 (0)