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-12 12:33:22 +00:00
|
|
|
security_group_ids = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.id,
|
|
|
|
resource.openstack_networking_secgroup_v2.kubenode.id
|
|
|
|
]
|
2024-01-11 14:34:07 +00:00
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
2024-01-12 10:11:10 +00:00
|
|
|
resource "openstack_blockstorage_volume_v3" "kubevolumeboot" {
|
2024-01-11 14:58:43 +00:00
|
|
|
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 15:44:01 +00:00
|
|
|
description = "OS volume for kubernetes node ${count.index + 1}"
|
2024-01-11 14:58:43 +00:00
|
|
|
size = 30
|
2024-01-12 10:11:10 +00:00
|
|
|
image_id = data.openstack_images_image_v2.debian12image.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_blockstorage_volume_v3" "kubevolumesnap" {
|
|
|
|
count = var.kubesize # size of cluster
|
|
|
|
name = "kube${count.index + 1}-matrix-test-sunet-se-vol"
|
|
|
|
description = "OS volume for kubernetes node ${count.index + 1}"
|
|
|
|
size = 50
|
2024-01-11 14:58:43 +00:00
|
|
|
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
|
2024-01-12 12:33:22 +00:00
|
|
|
security_groups = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.name,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.name,
|
|
|
|
resource.openstack_networking_secgroup_v2.kubenode.name
|
|
|
|
]
|
2024-01-12 13:08:02 +00:00
|
|
|
user_data = templatefile("kube-user.tpl",{})
|
2024-01-11 15:17:50 +00:00
|
|
|
|
|
|
|
network {
|
|
|
|
port = resource.openstack_networking_port_v2.kubeport[count.index].id
|
|
|
|
}
|
2024-01-12 10:23:58 +00:00
|
|
|
|
2024-01-11 15:17:50 +00:00
|
|
|
block_device {
|
2024-01-12 10:11:10 +00:00
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.kubevolumeboot[count.index].id
|
2024-01-11 15:17:50 +00:00
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
2024-01-12 10:23:58 +00:00
|
|
|
boot_index = 0
|
2024-01-11 15:17:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-12 18:31:54 +00:00
|
|
|
resource "openstack_compute_volume_attach_v2" "snapvolattach" {
|
|
|
|
instance_id = openstack_compute_instance_v2.kube[count.index].id
|
|
|
|
volume_id = openstack_blockstorage_volume_v3.kubevolumesnap[count.index].id
|
|
|
|
count = var.kubesize
|
2024-01-12 18:36:34 +00:00
|
|
|
depends_on = [ resource.openstack_compute_instance_v2.kube[count.index] ]
|
2024-01-12 18:31:54 +00:00
|
|
|
}
|