Compare commits

...

2 commits

2 changed files with 63 additions and 4 deletions

View file

@ -1,16 +1,75 @@
#
# Controller node resources
# Global definitions for sto4
#
locals {
dc = "sto4"
nodenrbase = index(var.datacenters, "sto4")
indexjump = length(var.datacenters)
}
resource "openstack_networking_port_v2" "kubewport-sto4" {
#
# Controller node resources
#
resource "openstack_networking_port_v2" "kubecport-sto4" {
name = "${var.controller_name}${count.index * local.indexjump + 1 + local.nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dc}-port"
# We create as many ports as there are instances created
count = var.controllerdcreplicas
network_id = data.openstack_networking_network_v2.public-sto4.id
# A list of security group ID
security_group_ids = [
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto4.id,
resource.openstack_networking_secgroup_v2.microk8s-sto4.id
]
admin_state_up = "true"
provider = openstack.sto4
}
# Boot volume for node
resource "openstack_blockstorage_volume_v3" "kubecvolumeboot-sto4" {
count = var.workerdcreplicas # Replicas per datacenter
name = "${var.controller_name}${count.index * local.indexjump + 1 + local.nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dc}-vol"
description = "OS volume for kubernetes worker node ${count.index * local.indexjump + 1 + local.nodenrbase}"
size = 100
image_id = data.openstack_images_image_v2.debian12image-sto4.id
enable_online_resize = true # Allow us to resize volume while attached.
provider = openstack.sto4
}
resource "openstack_compute_instance_v2" "controller-nodes-sto4" {
count = var.controllerdcreplicas # Replicas per datacenter
name = "${var.controller_name}${count.index * local.indexjump + 1 + local.nodenrbase}.${var.dns_suffix}"
flavor_name = "${var.controller_instance_type}"
key_pair = "${var.keynameworkers}"
provider = openstack.sto4
security_groups = [
resource.openstack_networking_secgroup_v2.microk8s-sto4.name,
resource.openstack_networking_secgroup_v2.ssh-from-jump-hosts-sto4.name
]
block_device {
uuid = resource.openstack_blockstorage_volume_v3.kubecvolumeboot-sto4[count.index].id
source_type = "volume"
destination_type = "volume"
boot_index = 0
}
scheduler_hints {
group = openstack_compute_servergroup_v2.controllers-sto4.id
}
network {
port = resource.openstack_networking_port_v2.kubecport-sto4[count.index].id
}
}
#
# Worker node resources
#
resource "openstack_networking_port_v2" "kubewport-sto4" {
name = "${var.worker_name}${count.index * local.indexjump + 1 + local.nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dc}-port"
# We create as many ports as there are instances created
count = var.workerdcreplicas
network_id = data.openstack_networking_network_v2.public-sto4.id
# A list of security group ID

View file

@ -44,7 +44,7 @@ variable "workerdcreplicas" {
# Replicas per datacenter
variable "controllerdcreplicas" {
default = "2"
default = "1"
}