# Repository Briefing: sgl-project/rbg
> Source: https://repoforai.com/repo/sgl-project/rbg (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/sgl-project/rbg
- **Official Docs / Website**: https://rolebasedgroup.github.io/
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Go
- **License**: Apache-2.0
- **Engineering Health**: A+ (90/100 · Maintenance 35/35 · Adoption 18/25 · Releases 17/20 · License 20/20)
- **Latest Release**: v0.8.0 (2026-08-31) — https://github.com/sgl-project/rbg/releases
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: Docker, Self-Hosted, API
- **Momentum**: 318 ★ total (+0 24h / +0 7d) · 97 forks
- **Topics**: `k8s`, `llm`, `pd-disagg`, `sglang`
- **When to Use**: Best for: Kubernetes platform teams deploying prefill/decode-disaggregated or multi-node inference that needs role-aware placement, controlled startup, and coordinated rollouts or scaling. Skip if: You need a model server or hosted inference API, or your workload is a single role that a Deployment or StatefulSet can manage without cross-role policies.

## Overview
```text
### Architecture & Core Mechanics
RoleBasedGroup (RBG) is a Kubernetes control plane for inference workloads, not an inference engine. A `workloads.x-k8s.io/v1alpha2` RoleBasedGroup models a service as named roles, each with its own replica count, Pod template, and lifecycle settings. Dependencies gate startup on role readiness. RoleInstance groups Pods that share a lifecycle and supports in-place updates; RoleInstanceSet is the preferred workload type. CoordinatedPolicy is a separate CRD for operations that span roles.

The Go module is `sigs.k8s.io/rbgs` and declares Go 1.25.0, Kubernetes API and client libraries at v0.34.2, and OpenKruise v1.8.3. The tree separates API definitions (`api/`), client code (`client-go/`), and command entrypoints (`cmd/`). The image runs `/manager` and also ships `kubectl-rbg`. The integration boundary is the Kubernetes API and the Pod templates: RBG defines how the workload is organized and reconciled, while the containers implement model serving.

### Key Capabilities & Differentiators
A role can use `standalonePattern` for one Pod per instance or `leaderWorkerPattern` for a distributed replica with a leader and workers. This lets a service mix single-Pod roles with multi-node tensor-parallel roles. Reusable role templates accept role-specific patches. RoleID injection and built-in discovery give workloads stable role identities and a way to discover peers; CoordinatedPolicy exposes `maxSkew` and `progression` for cross-role rollouts and scaling.

The SGLang examples cover both aggregated and prefill/decode-disaggregated serving. Dynamo examples cover both layouts, including multi-node variants. Mooncake examples cover KV-cache reuse and separate transfer-engine configurations for SGLang and vLLM. Topology-aware placement is intended to account for GPU interconnect and network locality, while gang-scheduling examples use Volcano or scheduler-plugins. These mechanisms help express placement and coordination requirements; they do not establish a throughput or latency improvement on a given cluster.

### Trade-offs & Limitations
Compared with independent Deployments or StatefulSets, RBG makes startup dependencies, coordinated rollouts, and linked recovery part of the workload model rather than leaving them to scripts or operators. LeaderWorkerSet addresses the leader-worker grouping problem; RBG adds coordination among distinct roles that may have different replica layouts. For a single inference server, or for services whose roles can safely evolve independently, the native primitives are usually the simpler choice.

The cost is an additional controller, custom resources and webhooks, and an API migration path to manage. Compatibility mode keeps existing legacy workloads reconciling but rejects new uses; strict mode removes the corresponding watches and permissions and rejects legacy types on create and update. Gang scheduling and placement constraints can also leave replicas pending if the cluster cannot satisfy them, so validate scheduling with realistic GPU inventory. Apache-2.0 covers RBG itself, not the terms of model weights or third-party runtime images.

### Hardware & Deployment Guide
Self-host on Kubernetes using Helm and pin the release chart after checking its compatibility guidance. The compatibility table lists v0.7.0 with Kubernetes v1.22.x or later and no LeaderWorkerSet requirement; v0.6.0 lists Kubernetes v1.28.x or later and LeaderWorkerSet v0.7.0 or later. Do not extrapolate that matrix to newer tags. The Docker build uses Go 1.26.6, produces the manager and CLI with `make build` and `make build-cli`, and ships them on Alpine. `/manager` runs as UID/GID 65532; a replacement base image must preserve `/bin/sleep` for the manager's preStop hook.

For new clusters, disable deprecated workload types and use RoleInstanceSet. On upgrades with legacy roles, keep compatibility mode until migration and reconciliation have completed and old RBG-owned workloads are gone, then disable it. The v0.7.0 milestone introduced conversion webhooks, coordinated policies, and gang scheduling alongside v1alpha2. The v0.9.0 alpha series separately records work on webhook shutdown draining, exclusive topology scheduling, and RoleInstance restart-budget handling. For GPU serving, provision the engine images, model artifacts, GPU capacity, and network independently of the controller.
```

## Key Capabilities
```text
- Service topology: v1alpha2 RoleBasedGroup combines role dependencies, stable RoleID injection, and built-in service discovery.
- Replica layout: standalonePattern uses one Pod per instance; leaderWorkerPattern represents a leader and workers for distributed execution.
- Lifecycle coordination: CoordinatedPolicy uses maxSkew and progression to govern rolling updates and scaling across roles.
- Placement: Topology-aware affinity covers GPU interconnect and network locality; gang-scheduling examples target Volcano and scheduler-plugins.
- Runtime integrations: SGLang examples cover aggregated and prefill/decode-disaggregated serving, with separate Dynamo and Mooncake examples.
- Migration controls: controller.deprecatedWorkloadTypes.enabled determines whether remaining legacy workloads can continue to reconcile.
```

## Quick Start / Clone
```bash
VERSION=$(curl -sL https://api.github.com/repos/sgl-project/rbg/releases/latest | grep '"tag_name"' | sed -E 's/.*"v([^"]+)".*/\1/')
helm upgrade --install rbgs https://github.com/sgl-project/rbg/releases/download/v$VERSION/rbgs-$VERSION.tgz \
            --namespace rbgs-system --create-namespace --wait
```
