Prepare terraform manifests for two workers in sto4.
This commit is contained in:
parent
83c3d61b77
commit
b53cd52314
|
@ -3,3 +3,10 @@ data "openstack_images_image_v2" "debian12image" {
|
||||||
name = "debian-12" # Name of image to be used
|
name = "debian-12" # Name of image to be used
|
||||||
most_recent = true
|
most_recent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data "openstack_images_image_v2" "debian12image-sto4" {
|
||||||
|
name = "debian-12" # Name of image to be used
|
||||||
|
most_recent = true
|
||||||
|
provider = openstack.sto4
|
||||||
|
}
|
||||||
|
|
||||||
|
|
74
IaC-test/k8snodes-sto4.tf
Normal file
74
IaC-test/k8snodes-sto4.tf
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
#
|
||||||
|
# Controller node resources
|
||||||
|
#
|
||||||
|
|
||||||
|
locals {
|
||||||
|
dc = "sto4"
|
||||||
|
nodenrbase = index(var.datacenters, "sto4")
|
||||||
|
indexjump = length(var.datacenters)
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_networking_port_v2" "kubewport-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.workerdcreplicas
|
||||||
|
network_id = data.openstack_networking_network_v2.public-sto4.id
|
||||||
|
# A list of security group ID
|
||||||
|
security_group_ids = [
|
||||||
|
# data.openstack_networking_secgroup_v2.sshfromjumphosts.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" "kubewvolumeboot-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_blockstorage_volume_v3" "kubewvolumerook-sto4" {
|
||||||
|
count = var.workerdcreplicas # Replicas per datacenter
|
||||||
|
name = "${var.controller_name}${count.index * local.indexjump + 1 + local.nodenrbase}-${replace(var.dns_suffix,".","-")}-${local.dc}-rook-vol"
|
||||||
|
description = "Rook storage volume for kubernetes worker node ${count.index * local.indexjump + 1 + local.nodenrbase}"
|
||||||
|
size = 100
|
||||||
|
enable_online_resize = true # Allow us to resize volume while attached.
|
||||||
|
provider = openstack.sto4
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "openstack_compute_instance_v2" "worker-nodes-sto4" {
|
||||||
|
count = var.workerdcreplicas # Replicas per datacenter
|
||||||
|
name = "${var.worker_name}${count.index * local.indexjump + 1 + local.nodenrbase}.${var.dns_suffix}"
|
||||||
|
flavor_name = "${var.worker_instance_type}"
|
||||||
|
key_pair = "${var.keynameworkers}"
|
||||||
|
provider = openstack.sto4
|
||||||
|
security_groups = [
|
||||||
|
resource.openstack_networking_secgroup_v2.microk8s-sto4.name
|
||||||
|
]
|
||||||
|
|
||||||
|
block_device {
|
||||||
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumeboot-sto4[count.index].id
|
||||||
|
source_type = "volume"
|
||||||
|
destination_type = "volume"
|
||||||
|
boot_index = 0
|
||||||
|
}
|
||||||
|
block_device {
|
||||||
|
uuid = resource.openstack_blockstorage_volume_v3.kubewvolumerook-sto4[count.index].id
|
||||||
|
source_type = "volume"
|
||||||
|
destination_type = "volume"
|
||||||
|
boot_index = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduler_hints {
|
||||||
|
group = openstack_compute_servergroup_v2.workers-sto4.id
|
||||||
|
}
|
||||||
|
network {
|
||||||
|
port = resource.openstack_networking_port_v2.kubewport-sto4[count.index].id
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
data "openstack_networking_network_v2" "public" {
|
data "openstack_networking_network_v2" "public" {
|
||||||
name = "public" # Name of network to use.
|
name = "public" # Name of network to use.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data "openstack_networking_network_v2" "public-sto4" {
|
||||||
|
name = "public" # Name of network to use.
|
||||||
|
provider = openstack.sto4
|
||||||
|
}
|
||||||
|
|
11
IaC-test/servergroups-sto4.tf
Normal file
11
IaC-test/servergroups-sto4.tf
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
resource "openstack_compute_servergroup_v2" "workers-sto4" {
|
||||||
|
name = "workers"
|
||||||
|
policies = ["anti-affinity"]
|
||||||
|
provider = openstack.sto4
|
||||||
|
}
|
||||||
|
resource "openstack_compute_servergroup_v2" "controllers-sto4" {
|
||||||
|
name = "controllers"
|
||||||
|
policies = ["anti-affinity"]
|
||||||
|
provider = openstack.sto4
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,12 @@ variable "keynameworkers" {
|
||||||
variable "worker_instance_count" {
|
variable "worker_instance_count" {
|
||||||
default = "2"
|
default = "2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Replicas per datacenter
|
||||||
|
variable "workerdcreplicas" {
|
||||||
|
default = "2"
|
||||||
|
}
|
||||||
|
|
||||||
variable "controller_instance_count" {
|
variable "controller_instance_count" {
|
||||||
default = "3"
|
default = "3"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue