From d7cd55318ceb430729fdfe409da680359508ebd1 Mon Sep 17 00:00:00 2001 From: Daman Arora Date: Mon, 26 Jan 2026 14:56:55 -0500 Subject: [PATCH 1/2] add affinity group support for CKS cluster nodes --- .../plugins/cloudstack-kubernetes-service.rst | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/source/plugins/cloudstack-kubernetes-service.rst b/source/plugins/cloudstack-kubernetes-service.rst index 0682162359..e5fe8864c8 100644 --- a/source/plugins/cloudstack-kubernetes-service.rst +++ b/source/plugins/cloudstack-kubernetes-service.rst @@ -653,6 +653,44 @@ Administrators are able to dedicate hosts to a domain or account. CloudStack wil .. note:: By design the hosts dedication does not consider the deployment of system VMs on the dedicated hosts (SSVM, CPVM and Virtual Routers). In case the Kubernetes cluster is created on an unimplemented network then the Virtual Router of the network will not be deployed on the dedicated hosts. +Affinity groups for CKS cluster nodes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +From 4.23.0 onwards, users can specify host affinity or anti-affinity groups for different types of Kubernetes cluster nodes (control, worker, etcd) during cluster creation. This provides control over VM placement on hosts for high availability requirements. + +To use affinity groups with CKS clusters: + +1. Create the desired affinity groups (host affinity or host anti-affinity) beforehand using the CloudStack UI or API. + +2. When creating a Kubernetes cluster, specify the affinity group mapping using the **nodeaffinitygroups** parameter. This parameter accepts a mapping of node types to affinity group UUIDs with two fields per entry: + + - ``node``: The node type (permitted values: ``worker``, ``control``, ``etcd``) + - ``affinitygroup``: The UUID of the desired affinity group + +Example using the API: + +.. code-block:: bash + + cmk create kubernetescluster name=MyCluster zoneid= kubernetesversionid= serviceofferingid= size=3 nodeaffinitygroups[0].node=worker nodeaffinitygroups[0].affinitygroup= + +Multiple affinity groups can be assigned to a single node type by providing comma-separated UUIDs: + +.. code-block:: bash + + nodeaffinitygroups[0].affinitygroup=, + +Different node types can have different affinity group configurations: + +.. code-block:: bash + + nodeaffinitygroups[0].node=control nodeaffinitygroups[0].affinitygroup= nodeaffinitygroups[1].node=worker nodeaffinitygroups[1].affinitygroup= + +The affinity group configuration is persisted and automatically applied when scaling the cluster - new worker nodes inherit the affinity group settings without requiring additional parameters. + +.. note:: + - When used together with host dedication, affinity group rules are applied within the set of dedicated hosts. + - When adding external worker nodes to an existing cluster using ``addNodesToKubernetesCluster``, the nodes are validated against any worker affinity groups configured for the cluster. + Use diverse CNI plugins (Calico, Cilium, etc) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From d58f4aa92f49ee5fea461bd634c79182b97ff947 Mon Sep 17 00:00:00 2001 From: Daman Arora Date: Mon, 26 Jan 2026 15:00:18 -0500 Subject: [PATCH 2/2] simplify notes --- source/plugins/cloudstack-kubernetes-service.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/source/plugins/cloudstack-kubernetes-service.rst b/source/plugins/cloudstack-kubernetes-service.rst index e5fe8864c8..ea3a064b6c 100644 --- a/source/plugins/cloudstack-kubernetes-service.rst +++ b/source/plugins/cloudstack-kubernetes-service.rst @@ -688,7 +688,6 @@ Different node types can have different affinity group configurations: The affinity group configuration is persisted and automatically applied when scaling the cluster - new worker nodes inherit the affinity group settings without requiring additional parameters. .. note:: - - When used together with host dedication, affinity group rules are applied within the set of dedicated hosts. - When adding external worker nodes to an existing cluster using ``addNodesToKubernetesCluster``, the nodes are validated against any worker affinity groups configured for the cluster. Use diverse CNI plugins (Calico, Cilium, etc)