feat: pod port allocator (kep 171)#210
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial new feature for RBG applications: dynamic pod port allocation. It aims to solve the problem of port conflicts when deploying services, especially large language models (LLMs) that often require Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a port allocation mechanism for the RBG (RoleBasedGroup) system. It includes changes to the main application, a new controller for managing port allocation, and a KEP (Kubernetes Enhancement Proposal) document detailing the design and implementation. The changes involve adding new flags for configuring the port allocator, integrating the port allocator into the RBG controller, and implementing ConfigMap management for storing port assignments. The code introduces a new port-allocator package with functionalities for allocating, releasing, and managing ports using ConfigMaps. The KEP document provides a comprehensive overview of the motivation, goals, proposal, design details, and test plan for the pod port allocation feature.
28eaf8e to
c224b82
Compare
|
@NoobDream2568 Thanks a lot for your contribution. I think port allocation is not a controller-wide mandatory behavior. It is an object-level opt-in feature: some Because of that, the reconciler path should stay backend-agnostic and only express the lifecycle semantics. It should not directly encode In particular, I think code at this layer should say something like: Cleanup()meaning:
But it should not directly construct ConfigMap names and call ConfigMap-specific cleanup helpers such as: GetInstancePortConfigMapName(... )
ReleasePortsAndDeleteCM(...)For an object-level opt-in feature, those backend details should stay inside the port-allocation subsystem. |
c224b82 to
117f49c
Compare
117f49c to
ac5de64
Compare
e724cf2 to
450f196
Compare
616ea6b to
ccbe364
Compare
There was a problem hiding this comment.
Pull request overview
Implements KEP-171 “Pod Port Allocation” by introducing a port allocator subsystem, wiring it into RoleInstanceSet/RoleInstance reconciliation, and adding unit + e2e coverage to validate port annotation/env injection and reference resolution.
Changes:
- Add
pkg/port-allocator(config parsing, allocation/injection helpers, random policy, unit tests). - Integrate port allocation into RoleInstanceSet creation (RoleScoped) and RoleInstance/pod creation (PodScoped + env/annotation injection).
- Add KEP docs and an e2e testcase for the end-to-end port allocation flow.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/envtest/testutil/setup.go | Register v1alpha2 scheme for tests. |
| test/e2e/e2e_test.go | Add port allocator test suite to e2e run. |
| test/e2e/testcase/v1alpha2/port_allocator.go | New e2e validating RoleScoped/PodScoped allocation + injection + reference env. |
| pkg/reconciler/roleinstanceset_reconciler.go | Allocate RoleScoped ports and store on RoleInstanceSet annotations. |
| pkg/reconciler/roleinstanceset/statelessmode/core/implement.go | Allocate/copy ports onto new RoleInstances in stateless mode. |
| pkg/reconciler/roleinstanceset/statefulmode/stateful_instance_set_utils.go | Allocate/copy ports onto new RoleInstances in stateful mode. |
| pkg/reconciler/roleinstance/sync/instance_scale.go | Inject resolved ports into Pod env/annotations at pod creation time. |
| pkg/port-allocator/type.go | Define port allocator config types/scopes. |
| pkg/port-allocator/parser.go | Parse/validate allocator config + reference parsing helpers. |
| pkg/port-allocator/manager.go | Allocation/injection logic and annotation key formatting. |
| pkg/port-allocator/port_allocator.go | Global allocator singleton + setup/registration plumbing. |
| pkg/port-allocator/random.go | “random” allocation policy implementation. |
| pkg/port-allocator/*_test.go | Unit tests for parsing, allocation, injection, random policy. |
| keps/171-pod-port-allocation/kep.yaml | KEP metadata for feature tracking. |
| keps/171-pod-port-allocation/README.md | Detailed design/spec for port allocation feature. |
| cmd/rbgs/main.go | Add flags and initialize allocator at controller startup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ccbe364 to
871e59b
Compare
871e59b to
59839e0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ⅰ. Motivation
Ⅱ. Modifications
Ⅲ. Does this pull request fix one issue?
fixes #XXXX
Ⅳ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
Ⅴ. Describe how to verify it
VI. Special notes for reviews
Checklist
make fmt.