From 39c12c1d44c2818c0d4f646aee79124f57f30374 Mon Sep 17 00:00:00 2001 From: Jan Dittrich Date: Fri, 16 Aug 2024 15:40:53 +0200 Subject: [PATCH] Add server groups to OpenStack example Signed-off-by: Jan Dittrich --- examples/terraform/openstack/README.md | 4 +++- examples/terraform/openstack/control_plane.tf | 9 +++++++++ examples/terraform/openstack/variables.tf | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/terraform/openstack/README.md b/examples/terraform/openstack/README.md index 65a60120c..38ad1f51e 100644 --- a/examples/terraform/openstack/README.md +++ b/examples/terraform/openstack/README.md @@ -23,7 +23,7 @@ See the [Terraform loadbalancers in examples document][docs-tf-loadbalancer]. | Name | Version | |------|---------| -| [openstack](#provider\_openstack) | ~> 1.52.0 | +| [openstack](#provider\_openstack) | 1.52.1 | ## Modules @@ -36,6 +36,7 @@ No modules. | [openstack_compute_instance_v2.bastion](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_instance_v2) | resource | | [openstack_compute_instance_v2.control_plane](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_instance_v2) | resource | | [openstack_compute_keypair_v2.deployer](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_keypair_v2) | resource | +| [openstack_compute_servergroup_v2.control_plane](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_servergroup_v2) | resource | | [openstack_lb_listener_v2.kube_apiserver](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/lb_listener_v2) | resource | | [openstack_lb_loadbalancer_v2.kube_apiserver](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/lb_loadbalancer_v2) | resource | | [openstack_lb_member_v2.kube_apiserver](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/lb_member_v2) | resource | @@ -73,6 +74,7 @@ No modules. | [cluster\_name](#input\_cluster\_name) | Name of the cluster | `string` | n/a | yes | | [config\_drive](#input\_config\_drive) | If enabled, metadata for machines is stored on a configuration drive instead of the metadata service. | `bool` | `false` | no | | [control\_plane\_flavor](#input\_control\_plane\_flavor) | OpenStack instance flavor for the control plane nodes | `string` | `"m1.small"` | no | +| [control\_plane\_group\_policy](#input\_control\_plane\_group\_policy) | OpenStack instance group policy for the control plane nodes. Cannot be changed without recreating VMs! | `string` | `"soft-anti-affinity"` | no | | [control\_plane\_vm\_count](#input\_control\_plane\_vm\_count) | number of control plane instances | `number` | `3` | no | | [external\_network\_name](#input\_external\_network\_name) | OpenStack external network name | `string` | n/a | yes | | [image](#input\_image) | image name to use | `string` | `""` | no | diff --git a/examples/terraform/openstack/control_plane.tf b/examples/terraform/openstack/control_plane.tf index fdb75222f..f7368ec12 100644 --- a/examples/terraform/openstack/control_plane.tf +++ b/examples/terraform/openstack/control_plane.tf @@ -14,6 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +resource "openstack_compute_servergroup_v2" "control_plane" { + name = "${var.cluster_name}-control_plane" + policies = [var.control_plane_group_policy] +} + resource "openstack_networking_port_v2" "control_plane" { count = var.control_plane_vm_count name = "${var.cluster_name}-control_plane-${count.index}" @@ -37,6 +42,10 @@ resource "openstack_compute_instance_v2" "control_plane" { security_groups = [openstack_networking_secgroup_v2.securitygroup.name] config_drive = var.config_drive + scheduler_hints { + group = openstack_compute_servergroup_v2.control_plane.id + } + network { port = element(openstack_networking_port_v2.control_plane[*].id, count.index) } diff --git a/examples/terraform/openstack/variables.tf b/examples/terraform/openstack/variables.tf index 273ce89a1..9c807a219 100644 --- a/examples/terraform/openstack/variables.tf +++ b/examples/terraform/openstack/variables.tf @@ -88,6 +88,12 @@ variable "control_plane_flavor" { type = string } +variable "control_plane_group_policy" { + description = "OpenStack instance group policy for the control plane nodes. Cannot be changed without recreating VMs!" + default = "soft-anti-affinity" + type = string +} + # Worker Node Variables variable "worker_os" { description = "OS to run on worker machines"