diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..6b360ab --- /dev/null +++ b/main.tf @@ -0,0 +1,36 @@ +# Define required providers +terraform { +required_version = ">= 0.14.0" + required_providers { + openstack = { + source = "terraform-provider-openstack/openstack" + version = "~> 1.53.0" + } + } +} + +# Configure the OpenStack Provider +provider "openstack" { + cloud = "sto4-rut" +} + +resource "openstack_compute_instance_v2" "worker-nodes" { + count = var.instance_count + name = "${var.worker_name}-${count.index}.${var.dns_suffix}" + flavor_id = "${var.instance_type}" + 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" + volume_size = 20 + boot_index = 0 + destination_type = "volume" + delete_on_termination = true + } + + network { + name = "public" + } +} diff --git a/vars.tf b/vars.tf new file mode 100644 index 0000000..afda0e3 --- /dev/null +++ b/vars.tf @@ -0,0 +1,13 @@ +variable "instance_count" { + default = "6" +} + +variable "instance_type" { + default = "e2677a72-f9ab-44ce-b808-58ab3414bac6" +} +variable "worker_name" { + default = "internal-sto4-test-k8sw" +} +variable "dns_suffix" { + default = "rut.sunet.se" +}