sgl-router: experimental Rust HTTP router for SGLang worker pools (#25851)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kangyan-Zhou
2026-05-25 15:34:05 +08:00
committed by GitHub
co-authored by Claude Opus 4.7
parent aae04b1241
commit 6e8fe176be
131 changed files with 28623 additions and 55 deletions
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: sgl-router-test
@@ -0,0 +1,33 @@
# Cluster-wide RBAC for the cross-namespace discovery test.
# Distinct ServiceAccount/ClusterRole names to avoid collision with
# the namespace-scoped Role in rbac.yaml used by the default router.
apiVersion: v1
kind: ServiceAccount
metadata:
name: sgl-router-cluster
namespace: sgl-router-test
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: sgl-router-cluster
rules:
- apiGroups: ["discovery.k8s.io"]
resources: ["endpointslices"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["services", "pods"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: sgl-router-cluster
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: sgl-router-cluster
subjects:
- kind: ServiceAccount
name: sgl-router-cluster
namespace: sgl-router-test
@@ -0,0 +1,34 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: sgl-router
namespace: sgl-router-test
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: sgl-router
namespace: sgl-router-test
rules:
# EndpointSlice watch (k8s discovery backend)
- apiGroups: ["discovery.k8s.io"]
resources: ["endpointslices"]
verbs: ["get", "list", "watch"]
# Service list/watch (needed to resolve EndpointSlice owner)
- apiGroups: [""]
resources: ["services", "pods"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: sgl-router
namespace: sgl-router-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: sgl-router
subjects:
- kind: ServiceAccount
name: sgl-router
namespace: sgl-router-test
@@ -0,0 +1,60 @@
# sgl-router deployment with ClusterRole for cross-namespace discovery test.
# Watches workers in ALL namespaces via cluster-scoped EndpointSlice access.
apiVersion: apps/v1
kind: Deployment
metadata:
name: sgl-router-cluster
namespace: sgl-router-test
spec:
replicas: 1
selector:
matchLabels:
app: sgl-router-cluster
template:
metadata:
labels:
app: sgl-router-cluster
spec:
serviceAccountName: sgl-router-cluster
containers:
- name: router
image: sgl-router:e2e
imagePullPolicy: Never
args:
- "--config"
- "/etc/config/router-cluster.toml"
ports:
- containerPort: 8091
name: http
readinessProbe:
httpGet:
path: /readyz
port: 8091
initialDelaySeconds: 3
periodSeconds: 3
livenessProbe:
httpGet:
path: /healthz
port: 8091
initialDelaySeconds: 5
periodSeconds: 10
volumeMounts:
- name: config
mountPath: /etc/config
volumes:
- name: config
configMap:
name: sgl-router-cluster-config
---
apiVersion: v1
kind: Service
metadata:
name: sgl-router-cluster
namespace: sgl-router-test
spec:
selector:
app: sgl-router-cluster
ports:
- name: http
port: 8091
targetPort: 8091
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sgl-router
namespace: sgl-router-test
spec:
replicas: 1
selector:
matchLabels:
app: sgl-router
template:
metadata:
labels:
app: sgl-router
spec:
serviceAccountName: sgl-router
containers:
- name: router
image: sgl-router:e2e
imagePullPolicy: Never
args:
- "--config"
- "/etc/config/router.toml"
ports:
- containerPort: 8090
name: http
readinessProbe:
httpGet:
path: /readyz
port: 8090
initialDelaySeconds: 3
periodSeconds: 3
livenessProbe:
httpGet:
path: /healthz
port: 8090
initialDelaySeconds: 5
periodSeconds: 10
volumeMounts:
- name: config
mountPath: /etc/config
volumes:
- name: config
configMap:
name: sgl-router-config
---
apiVersion: v1
kind: Service
metadata:
name: sgl-router
namespace: sgl-router-test
spec:
selector:
app: sgl-router
ports:
- name: http
port: 8090
targetPort: 8090