This controller controls the ResourceClaimAutoscaler (RCA) CRD to scale the Dynamic Resource Allocation (DRA)'s resource claim of LLM inference services on Kubernetes according to their metrics.
- Service-Based Discovery: Automatically detects workload owners (Deployment, StatefulSet) from Service endpoints
- Prometheus Integration: Collects metrics directly from Prometheus for traffic analysis and tuning
- Hint-based Estimation: Estimate resource requirements based on given model and GPU spec and hint.
- Multi-GPU Support: Accounts for multiple GPUs
- KV Cache Modeling: Accounts for cache hit rates and speedup factors
- Prefill/Decode Phases: Separate modeling of prompt processing and token generation
- Queue Theory-Based Prediction: Uses M/M/c queueing models with Erlang C formulas for latency estimation
- Resource Claim Life cycle Management: Manages patching scaling ResourceClaim
- Lookback Windows: Prevents thrashing with configurable lookback windows
- Rate-Limited Scaling: Gradual scale-up/down with percentage or pod-based policies
- Graceful Transitions: Configurable grace periods for smooth resource changes
The system requires administrators to install a monitoring stack (Prometheus) and DRA driver alongside this autoscaler. Three workflows cooperate to provide automated resource scaling:
Admin configures monitoring parameters (Prometheus endpoint, queries) via RCAControllerConfig CRD. When user creates ResourceClaimAutoscaler, the controller discovers the workload owner from the target Service.
Optimization: The optimizer uses queue-theory models (M/M/c with Erlang C formulas) to calculate optimal resource requirements based on collected metrics (arrival rate, latency, etc.).
For more details, see Resource Optimization Concept.
Scaling: The controller automatically detects the workload owner (Deployment, StatefulSet) and generates a new ResourceClaimTemplate with updated resource requests. It then patches the workload owner with the new template and replica count. Due to current DRA limitations (no in-place scaling), pods must be recreated with new ResourceClaims. The controller watches ResourceClaim events to update status and cleanup old templates.
For more details, see Controller Reconcile Workflows.
After the workload is patched with the new ResourceClaimTemplate, Kubernetes recreates pods with new resource claims. The DRA driver schedules these pods to nodes with available resources.
Build and push your image to the location specified by IMG:
make docker-build docker-push IMG=<some-registry>/rca-controller:tagNOTE: This image ought to be published in the personal registry you specified. And it is required to have access to pull the image from the working environment. Make sure you have the proper permission to the registry if the above commands donβt work.
Install the CRDs into the cluster:
make installDeploy the Manager to the cluster with the image specified by IMG:
make deploy IMG=<some-registry>/rca-controller:tagNOTE: If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin.
Create instances of your solution You can apply the samples (examples) from the config/sample:
kubectl apply -k config/samples/NOTE: Ensure that the samples has default values to test it out.
Delete the instances (CRs) from the cluster:
kubectl delete -k config/samples/Delete the APIs(CRDs) from the cluster:
make uninstallUnDeploy the controller from the cluster:
make undeployFollowing the options to release and provide this solution to the users.
- Build the installer for the image built and published in the registry:
make build-installer IMG=<some-registry>/rca-controller:tagNOTE: The makefile target mentioned above generates an 'install.yaml' file in the dist directory. This file contains all the resources built with Kustomize, which are necessary to install this project without its dependencies.
- Using the installer
Users can just run 'kubectl apply -f ' to install the project, i.e.:
kubectl apply -f https://raw.githubusercontent.com/<org>/rca-controller/<tag or branch>/dist/install.yaml- Build the chart using the optional helm plugin
operator-sdk edit --plugins=helm/v1-alpha- See that a chart was generated under 'dist/chart', and users can obtain this solution from there.
NOTE: If you change the project, you need to update the Helm Chart using the same command above to sync the latest changes. Furthermore, if you create webhooks, you need to use the above command with the '--force' flag and manually ensure that any custom configuration previously added to 'dist/chart/values.yaml' or 'dist/chart/manager/manager.yaml' is manually re-applied afterwards.
Please read and follow our Code Style Guide before contributing. Key points:
- Testing: Use Ginkgo/Gomega for all tests
- Quality: Always run
make lintandmake testbefore committing - Coverage: Maintain >70% test coverage for new code
- Documentation: Add godoc comments for all exported items
# Run all tests with coverage
make test
# Run linter
make lint
# Run both
make test lintBefore committing code:
-
make lintpasses with 0 issues -
make testpasses with all tests green -
make api-docsregenerates API documentation indocs/apiif API changed -
make manifestsregenerates CRDs if API changed
