2024-01-11 14:34:07 +00:00
|
|
|
|
|
|
|
resource "openstack_networking_port_v2" "kubeport" {
|
|
|
|
name = "kube${count.index + 1}-matrix-test-sunet-se-port"
|
|
|
|
# We create as many ports as there are instances created
|
2024-01-11 14:40:12 +00:00
|
|
|
count = var.kubesize # size of cluster
|
2024-01-11 14:34:07 +00:00
|
|
|
network_id = data.openstack_networking_network_v2.public.id
|
|
|
|
# A list of security group ID
|
2024-01-11 15:17:50 +00:00
|
|
|
security_group_ids = [ data.openstack_networking_secgroup_v2.sshfromjumphosts.id ]
|
2024-01-11 14:34:07 +00:00
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
2024-01-11 14:58:43 +00:00
|
|
|
resource "openstack_blockstorage_volume_v3" "kubevolume" {
|
|
|
|
count = var.kubesize # size of cluster
|
2024-01-11 15:39:19 +00:00
|
|
|
name = "kube${count.index + 1}-matrix-test-sunet-se-vol"
|
2024-01-11 14:58:43 +00:00
|
|
|
description = "OS volume for kubernetes node ${count.index}"
|
|
|
|
size = 30
|
|
|
|
image_id = data.openstack_images_image_v2.ubuntu2204image.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
}
|
2024-01-11 15:17:50 +00:00
|
|
|
|
|
|
|
# Create instances of kubernetes nodes
|
|
|
|
resource "openstack_compute_instance_v2" "kube" {
|
2024-01-11 15:39:19 +00:00
|
|
|
name = "kube${count.index + 1}.matrix-test.sunet.se"
|
2024-01-11 15:17:50 +00:00
|
|
|
count = var.kubesize
|
|
|
|
flavor_id = data.openstack_compute_flavor_v2.b2c4r16.id
|
|
|
|
key_pair = data.openstack_compute_keypair_v2.manderssonpub.id
|
|
|
|
security_groups = ["ssh-from-jumphost"]
|
|
|
|
|
|
|
|
network {
|
|
|
|
port = resource.openstack_networking_port_v2.kubeport[count.index].id
|
|
|
|
}
|
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubevolume[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|