Skip to content

feat(helm): add affinity and topologySpreadConstraints on Kagent controller and ui - #2365

Merged
EItanya merged 1 commit into
kagent-dev:mainfrom
anthonyhaussman:feat/helm-affinity-topology
Jul 31, 2026
Merged

EItanya merged 1 commit into
kagent-dev:mainfrom
anthonyhaussman:feat/helm-affinity-topology

Conversation

@anthonyhaussman

Copy link
Copy Markdown
Contributor

Adds support for setting affinity and topologySpreadConstraints on the controller and ui deployments via values.yaml. This allows for more advanced scheduling of these components.

@github-actions github-actions Bot added the enhancement New feature or request label Jul 30, 2026
@anthonyhaussman anthonyhaussman changed the title feat(helm): add affinity and topologySpreadConstraints feat(helm): add affinity and topologySpreadConstraints on Kagent controller and ui Jul 30, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 30, 2026
@anthonyhaussman
anthonyhaussman marked this pull request as ready for review July 30, 2026 16:38
@anthonyhaussman
anthonyhaussman requested a review from a team as a code owner July 30, 2026 16:38
Copilot AI review requested due to automatic review settings July 30, 2026 16:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds per-component pod scheduling configuration to the Helm chart so operators can apply Kubernetes affinity and topologySpreadConstraints to the Kagent controller and UI Deployments for more advanced placement and resiliency.

Changes:

  • Exposes controller.affinity / controller.topologySpreadConstraints and ui.affinity / ui.topologySpreadConstraints in values.yaml.
  • Renders those values into the controller and UI Deployment pod specs only when non-empty.
  • Adds Helm unit tests to validate rendering behavior (set vs. default not rendered) for both components.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
helm/kagent/values.yaml Adds new user-facing values for controller/UI affinity and topology spread constraints.
helm/kagent/templates/ui-deployment.yaml Conditionally renders affinity and topologySpreadConstraints into the UI pod spec.
helm/kagent/templates/controller-deployment.yaml Conditionally renders affinity and topologySpreadConstraints into the controller pod spec.
helm/kagent/tests/ui-deployment_test.yaml Adds unit tests covering UI affinity/topologySpreadConstraints rendering and defaults.
helm/kagent/tests/controller-deployment_test.yaml Adds unit tests covering controller affinity/topologySpreadConstraints rendering and defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Support affinity and topology spread constraints on controller and ui deployments for advanced scheduling.

Assisted-by: GLM 5.2
Signed-off-by: Anthony Hausman <[email protected]>

@EItanya EItanya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, you will need to backport to get into v0.10.x

@EItanya
EItanya merged commit 77cea34 into kagent-dev:main Jul 31, 2026
30 checks passed
@anthonyhaussman
anthonyhaussman deleted the feat/helm-affinity-topology branch August 1, 2026 12:53
@anthonyhaussman
anthonyhaussman restored the feat/helm-affinity-topology branch August 2, 2026 15:55
@anthonyhaussman

Copy link
Copy Markdown
Contributor Author

LGTM, you will need to backport to get into v0.10.x

Good remark @EItanya , I have created a backport PR: #2378
🙏

EItanya pushed a commit that referenced this pull request Aug 3, 2026
EItanya pushed a commit that referenced this pull request Aug 25, 2026
## Summary

- The `controller` and `ui` deployments expose `nodeSelector`,
`tolerations` and
`affinity`, but the bundled PostgreSQL Deployment rendered by
`templates/postgresql.yaml` has no scheduling fields at all
- This makes the bundled database impossible to place. On a cluster with
a
dedicated, tainted node pool it cannot follow the rest of the control
plane, and
a single-replica PVC-backed database left on an autoscaled pool gets
drained
whenever that pool scales in — taking the controller down with it
- Adds `nodeSelector`, `tolerations` and `affinity` to
`database.postgres.bundled`, rendered with the same `{{- with }}` form
and in the
same order `controller-deployment.yaml` already uses
- Values documentation copies the wording already used by the
`controller` and
`ui` blocks, so the three read consistently
- Defaults stay empty, so rendered output is unchanged for existing
installs

Follows the same shape as #2213 (`nodeSelector`/`tolerations` for the
`kagent-tools` subchart) and #2365
(`affinity`/`topologySpreadConstraints` for
controller and ui), which closed the equivalent gap for other
components.

## Test plan

- [x] `helm unittest helm/kagent` passes — 274 tests, including 4 new
ones in
`tests/postgresql_test.yaml` covering the unset, `nodeSelector`,
`tolerations`
and `affinity` cases
- [x] `helm template` with `database.postgres.bundled.nodeSelector` and
`tolerations` set renders both fields on the `kagent-postgresql`
Deployment pod
spec
- [x] `helm template` with the values unset renders no scheduling fields
on that
pod spec, confirming existing installs are unaffected

Signed-off-by: Carlos Landeras <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants