Skip to content

CKS: Allow affinity group selection during cluster creation#12386

Open
Damans227 wants to merge 47 commits intoapache:mainfrom
Damans227:implement-cks-node-affinity
Open

CKS: Allow affinity group selection during cluster creation#12386
Damans227 wants to merge 47 commits intoapache:mainfrom
Damans227:implement-cks-node-affinity

Conversation

@Damans227
Copy link
Contributor

@Damans227 Damans227 commented Jan 7, 2026

Description

This PR adds support for specifying affinity groups during CKS (CloudStack Kubernetes Service) cluster creation, allowing users to control VM placement for high availability.

Changes:

  • New nodeaffinitygroups parameter for createKubernetesCluster API
  • Supports per-node-type (CONTROL, WORKER, ETCD) affinity group assignment
  • New kubernetes_cluster_affinity_group_map table for normalized storage

Design doc:

https://cwiki.apache.org/confluence/display/CLOUDSTACK/Allow+users+to+select+affinity+group+during+managed+CKS+cluster+creation

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

cmk based api testing:

Screen recording

Screencast.from.2026-01-13.06-47-14.mp4

Screenshots

Screenshot from 2026-01-13 06-46-12 Screenshot from 2026-01-13 06-46-24 Screenshot from 2026-01-13 06-46-42

How Has This Been Tested?

How did you try to break this feature and the system with this change?

  • Invalid affinity group UUID
  • Invalid node type
  • Duplicate node type entries
  • Clusters without affinity groups (backward compatibility)

Daman Arora added 21 commits January 6, 2026 08:51
…ndling and enhance node type validation tests
@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16294

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 39.76834% with 312 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.94%. Comparing base (c465caf) to head (6f00ed7).
⚠️ Report is 228 commits behind head on main.

Files with missing lines Patch % Lines
...bernetes/cluster/KubernetesClusterManagerImpl.java 42.02% 116 Missing and 4 partials ⚠️
...r/actionworkers/KubernetesClusterActionWorker.java 28.84% 37 Missing ⚠️
...KubernetesClusterResourceModifierActionWorker.java 0.00% 36 Missing ⚠️
...er/actionworkers/KubernetesClusterScaleWorker.java 0.00% 31 Missing ⚠️
.../dao/KubernetesClusterAffinityGroupMapDaoImpl.java 0.00% 27 Missing ⚠️
...uster/UpdateKubernetesClusterAffinityGroupCmd.java 0.00% 25 Missing ⚠️
...ubernetes/cluster/KubernetesServiceHelperImpl.java 76.71% 16 Missing and 1 partial ⚠️
...er/actionworkers/KubernetesClusterStartWorker.java 0.00% 5 Missing ⚠️
...kubernetes/cluster/CreateKubernetesClusterCmd.java 0.00% 5 Missing ⚠️
...s/cluster/KubernetesClusterAffinityGroupMapVO.java 86.20% 3 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12386      +/-   ##
============================================
+ Coverage     17.76%   17.94%   +0.18%     
- Complexity    15859    16223     +364     
============================================
  Files          5923     5944      +21     
  Lines        530470   533807    +3337     
  Branches      64823    65330     +507     
============================================
+ Hits          94243    95812    +1569     
- Misses       425682   427248    +1566     
- Partials      10545    10747     +202     
Flag Coverage Δ
uitests 3.65% <ø> (+0.08%) ⬆️
unittests 19.06% <39.76%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaanHoogland DaanHoogland added this to the 4.23.0 milestone Jan 8, 2026
@weizhouapache weizhouapache linked an issue Feb 19, 2026 that may be closed by this pull request
@Damans227
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16885

@Damans227
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16915

@Damans227
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16919

@Damans227
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16949

@kiranchavala
Copy link
Member

@blueorangutan test

Copy link
Member

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

LGTM

Test Case Execution Result
Test affinity groups on cks control nodes Pass
Test affinity groups on cks worker nodes Pass
Test affinity groups on cks etcd nodes Pass
Test differnet affinity groups on both cks control and worker nodes Pass
Test manual scaling of cks cluster which has affinity groups present on control and worker nodes Pass
Test auto scaling of cks cluster which has affinity groups present on control and worker nodes Pass
Test changing of affinity groups on a stopped cks cluster Pass
Test changing of affinity groups on a cks instance which is part of a cks cluster Pass
Test creating of cks cluster which has invalid affinity group Pass
Test creating of cks cluster which has invalid node type Pass
Test the applying affinity groups on a cks cluster which was present before the upgarde Pass
Test listing of affinity groups for a user when creating a cks cluster Pass
Test the creation of affinity groups for a user from a admin user Pass
Test cks deployement with affinitygroups from a project Pass
Test the cks deployment with affinity groups from a user account Pass
Test scaling with affinity groups when there is no capacity on the hypervisor host Pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kubernetes nodes with affinity group

9 participants