use a new table kubernetes_cluster_affinity_group_map instead of existing kubernetes_cluster

This commit is contained in:
Daman Arora 2026-01-07 07:22:02 -05:00
parent 0706410a3f
commit a13f360bcd
3 changed files with 13 additions and 41 deletions

View File

@ -170,9 +170,6 @@ public interface KubernetesCluster extends ControlledEntity, com.cloud.utils.fsm
Long getWorkerNodeTemplateId();
Long getEtcdNodeTemplateId();
Long getEtcdNodeCount();
String getControlNodeAffinityGroupIds();
String getWorkerNodeAffinityGroupIds();
String getEtcdNodeAffinityGroupIds();
Long getCniConfigId();
String getCniConfigDetails();
boolean isCsiEnabled();

View File

@ -20,16 +20,24 @@
--;
-- Add affinity group columns to kubernetes_cluster table for CKS affinity group support
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.kubernetes_cluster', 'control_node_affinity_group_ids', 'VARCHAR(1024) DEFAULT NULL COMMENT "comma-separated affinity group UUIDs for control nodes"');
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.kubernetes_cluster', 'worker_node_affinity_group_ids', 'VARCHAR(1024) DEFAULT NULL COMMENT "comma-separated affinity group UUIDs for worker nodes"');
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.kubernetes_cluster', 'etcd_node_affinity_group_ids', 'VARCHAR(1024) DEFAULT NULL COMMENT "comma-separated affinity group UUIDs for etcd nodes"');
-- Update value to random for the config 'vm.allocation.algorithm' or 'volume.allocation.algorithm' if configured as userconcentratedpod_random
-- Update value to firstfit for the config 'vm.allocation.algorithm' or 'volume.allocation.algorithm' if configured as userconcentratedpod_firstfit
UPDATE `cloud`.`configuration` SET value='random' WHERE name IN ('vm.allocation.algorithm', 'volume.allocation.algorithm') AND value='userconcentratedpod_random';
UPDATE `cloud`.`configuration` SET value='firstfit' WHERE name IN ('vm.allocation.algorithm', 'volume.allocation.algorithm') AND value='userconcentratedpod_firstfit';
-- Create kubernetes_cluster_affinity_group_map table for CKS per-node-type affinity groups
CREATE TABLE IF NOT EXISTS `cloud`.`kubernetes_cluster_affinity_group_map` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`cluster_id` bigint unsigned NOT NULL COMMENT 'kubernetes cluster id',
`node_type` varchar(32) NOT NULL COMMENT 'CONTROL, WORKER, or ETCD',
`affinity_group_id` bigint unsigned NOT NULL COMMENT 'affinity group id',
PRIMARY KEY (`id`),
CONSTRAINT `fk_kubernetes_cluster_ag_map__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `kubernetes_cluster`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_kubernetes_cluster_ag_map__ag_id` FOREIGN KEY (`affinity_group_id`) REFERENCES `affinity_group`(`id`) ON DELETE CASCADE,
INDEX `i_kubernetes_cluster_ag_map__cluster_id`(`cluster_id`),
INDEX `i_kubernetes_cluster_ag_map__ag_id`(`affinity_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Create webhook_filter table
DROP TABLE IF EXISTS `cloud`.`webhook_filter`;
CREATE TABLE IF NOT EXISTS `cloud`.`webhook_filter` (

View File

@ -139,15 +139,6 @@ public class KubernetesClusterVO implements KubernetesCluster {
@Column(name = "etcd_node_template_id")
private Long etcdNodeTemplateId;
@Column(name = "control_node_affinity_group_ids", length = 1024)
private String controlNodeAffinityGroupIds;
@Column(name = "worker_node_affinity_group_ids", length = 1024)
private String workerNodeAffinityGroupIds;
@Column(name = "etcd_node_affinity_group_ids", length = 1024)
private String etcdNodeAffinityGroupIds;
@Column(name = "cni_config_id", nullable = true)
private Long cniConfigId = null;
@ -518,30 +509,6 @@ public class KubernetesClusterVO implements KubernetesCluster {
this.controlNodeTemplateId = controlNodeTemplateId;
}
public String getControlNodeAffinityGroupIds() {
return controlNodeAffinityGroupIds;
}
public void setControlNodeAffinityGroupIds(String controlNodeAffinityGroupIds) {
this.controlNodeAffinityGroupIds = controlNodeAffinityGroupIds;
}
public String getWorkerNodeAffinityGroupIds() {
return workerNodeAffinityGroupIds;
}
public void setWorkerNodeAffinityGroupIds(String workerNodeAffinityGroupIds) {
this.workerNodeAffinityGroupIds = workerNodeAffinityGroupIds;
}
public String getEtcdNodeAffinityGroupIds() {
return etcdNodeAffinityGroupIds;
}
public void setEtcdNodeAffinityGroupIds(String etcdNodeAffinityGroupIds) {
this.etcdNodeAffinityGroupIds = etcdNodeAffinityGroupIds;
}
public Long getCniConfigId() {
return cniConfigId;
}