Model server groups and add anti-affinity for vms not being scheduled on the same host.

This commit is contained in:
Mikael Frykholm 2024-04-17 10:56:22 +02:00
parent 1a2a483336
commit 4ab30f3fa6
Signed by: mifr
GPG key ID: 1467F9D69135C236

19
main.tf
View file

@ -13,6 +13,16 @@ required_version = ">= 0.14.0"
provider "openstack" {
cloud = "sto4-rut"
}
resource "openstack_compute_servergroup_v2" "workers" {
name = "workers"
policies = ["anti-affinity"]
}
resource "openstack_compute_servergroup_v2" "controllers" {
name = "controllers"
policies = ["anti-affinity"]
}
resource "openstack_networking_secgroup_v2" "microk8s" {
name = "microk8s"
description = "Traffic to allow between microk8s hosts"
@ -190,6 +200,7 @@ resource "openstack_compute_instance_v2" "controller-nodes" {
key_pair = "mifr-yubi"
security_groups = ["microk8s", "Allow SSH from SUNET jumphosts", "Allow ssh from the world"]
block_device {
uuid = "5d24aca9-11be-4de1-9770-4a097d68f361"
source_type = "image"
@ -198,7 +209,9 @@ resource "openstack_compute_instance_v2" "controller-nodes" {
destination_type = "volume"
delete_on_termination = true
}
scheduler_hints {
group = openstack_compute_servergroup_v2.controllers.id
}
network {
name = "public"
}
@ -218,7 +231,9 @@ resource "openstack_compute_instance_v2" "worker-nodes" {
destination_type = "volume"
delete_on_termination = true
}
scheduler_hints {
group = openstack_compute_servergroup_v2.workers.id
}
network {
name = "public"
}