Skip to content

Commit

Permalink
Allow the use of soft-anti-affinity for the control plane
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Hros <[email protected]>
  • Loading branch information
chess-knight committed Jun 21, 2024
1 parent 053c40a commit b46a69a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Parameters controlling the cluster creation:
| `` | `CONTROL_PLANE_ROOT_DISKSIZE` | SCS | `20` | *If* diskless flavors are used for control plane nodes, this is the allocated root volume disk size (in GB) |
| `` | `WORKER_ROOT_DISKSIZE` | SCS | `20` | *If* diskless flavors are used for worker nodes, this is the allocated root volume disk size (in GB) |
| `anti_affinity` | `OPENSTACK_ANTI_AFFINITY` | SCS | `true` | Use anti-affinity server groups to prevent k8s nodes on same host (soft for workers, hard for controllers) |
| `soft_anti_affinity_controller` | `OPENSTACK_SOFT_ANTI_AFFINITY_CONTROLLER` | SCS | `false` | Allow the use of soft-anti-affinity for the controllers (if `anti_affinity` is `true`) |
| `` | `OPENSTACK_SRVGRP_CONTROLLER` | SCS | `nonono` | Autogenerated if `anti_affinity` is `true`, eliminated otherwise |
| `` | `OPENSTACK_SRVGRP_WORKER` | SCS | `nonono` | Autogenerated if `anti_affinity` is `true`, eliminated otherwise |
| `deploy_occm` | `DEPLOY_OCCM` | SCS | `true` | Deploy the given version of OCCM into the cluster. `true` (default) chooses the latest version matching the k8s version. You can specify `master` to chose the upstream master branch. Don't disable this. |
Expand Down
2 changes: 1 addition & 1 deletion playbooks/templates/environment.tfvars.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ controller_metadata = {
}

# FIXME: Remove when CI runs on gx-scs2 environment(3+ physical machines for local ssd flavors)
anti_affinity = false
soft_anti_affinity_controller = true

controller_count = 3
worker_count = 3
Expand Down
1 change: 1 addition & 0 deletions terraform/environments/environment-default.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ node_cidr = "<CIDR>" # defaults to "10.8.0.0/20"
service_cidr = "<CIDR>" # defaults to "10.96.0.0/12"
pod_cidr = "<CIDR>" # defaults to "192.168.0.0/16"
anti_affinity = "<boolean>" # defaults to "true"
soft_anti_affinity_controller = "<boolean>" # defaults to "false"
use_cilium = "version/true/false" # defaults to "true", can also be set to "vx.y.z", also see cilium_binaries
use_ovn_lb_provider = "auto/true/false" # use OVN LB if available (auto) or force (true) or never (false)
deploy_nginx_ingress = "version/true/false" # defaults to "true", you can also set vX.Y.Z if you want
Expand Down
5 changes: 4 additions & 1 deletion terraform/files/bin/create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ if test "$CONTROL_PLANE_MACHINE_COUNT" -gt 0 && grep '^ *OPENSTACK_ANTI_AFFINITY
SRVGRP_CONTROLLER=$(echo "$SRVGRP" | grep "${PREFIX}-${CLUSTER_NAME}-controller" | sed 's/^\([0-9a-f\-]*\) .*$/\1/')
SRVGRP_WORKER=$(echo "$SRVGRP" | grep "${PREFIX}-${CLUSTER_NAME}-worker" | sed 's/^\([0-9a-f\-]*\) .*$/\1/')
if test -z "$SRVGRP_CONTROLLER"; then
SRVGRP_CONTROLLER=$(openstack --os-compute-api-version 2.15 server group create --policy anti-affinity -f value -c id ${PREFIX}-${CLUSTER_NAME}-controller)
ANTI_AFFINITY_POLICY_CONTROLLER=anti-affinity
SOFT_ANTI_AFFINITY_CONTROLLER=$(yq eval '.OPENSTACK_SOFT_ANTI_AFFINITY_CONTROLLER' $CCCFG)
if test "$SOFT_ANTI_AFFINITY_CONTROLLER" = "true"; then ANTI_AFFINITY_POLICY_CONTROLLER=soft-anti-affinity; fi
SRVGRP_CONTROLLER=$(openstack --os-compute-api-version 2.15 server group create --policy ${ANTI_AFFINITY_POLICY_CONTROLLER} -f value -c id ${PREFIX}-${CLUSTER_NAME}-controller)
SRVGRP_WORKER=$(openstack --os-compute-api-version 2.15 server group create --policy soft-anti-affinity -f value -c id ${PREFIX}-${CLUSTER_NAME}-worker)
fi
echo "Adding server groups $SRVGRP_CONTROLLER and $SRVGRP_WORKER to $CCCFG"
Expand Down
1 change: 1 addition & 0 deletions terraform/files/template/clusterctl.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ OPENSTACK_SSH_KEY_NAME: ${prefix}-keypair

# Use anti-affinity server groups
OPENSTACK_ANTI_AFFINITY: ${anti_affinity}
OPENSTACK_SOFT_ANTI_AFFINITY_CONTROLLER: ${soft_anti_affinity_controller}
OPENSTACK_SRVGRP_CONTROLLER: nonono
OPENSTACK_SRVGRP_WORKER: nonono

Expand Down
1 change: 1 addition & 0 deletions terraform/mgmtcluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ resource "terraform_data" "mgmtcluster_bootstrap_files" {
provisioner "file" {
content = templatefile("files/template/clusterctl.yaml.tmpl", {
anti_affinity = var.anti_affinity,
soft_anti_affinity_controller = var.soft_anti_affinity_controller,
availability_zone = var.availability_zone,
capo_instance_create_timeout = var.capo_instance_create_timeout,
cloud_provider = var.cloud_provider,
Expand Down
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ variable "anti_affinity" {
default = true
}

variable "soft_anti_affinity_controller" {
description = "allow the use of soft-anti-affinity for the control plane"
type = bool
default = false
}

variable "dns_nameservers" {
description = "array of nameservers to be set for subnets, prefer local DNS servers if available"
type = list(string)
Expand Down

0 comments on commit b46a69a

Please sign in to comment.