Compare commits

..

No commits in common. "19c3cf4a615e9fd1ef136cd4d1c101a52a9ea6ed" and "e863a8c0731615c7101617a098452b1e8d8c7f71" have entirely different histories.

6 changed files with 2 additions and 4891 deletions

View File

@ -3,8 +3,7 @@
"allow": [
"Bash(terraform init:*)",
"Bash(terraform validate:*)",
"Bash(terraform plan:*)",
"Bash(xargs cat:*)"
"Bash(terraform plan:*)"
]
}
}

3
.gitignore vendored
View File

@ -38,6 +38,7 @@ terraform.rc
# output plans
*-plan.zip
# Ignore ssh_key_file_ref
**/ssh-key-ref-outputs.tf
@ -46,5 +47,3 @@ terraform.rc
.project
.vscode/settings.json
.claude/

View File

@ -1,137 +0,0 @@
# Kubernetes course VMs for InfraScience
# 14 Ubuntu 24.04 VMs with m1.large flavor, 100GB root volume, 200GB data volume,
# floating IP and DNS record each.
data "terraform_remote_state" "privnet_dns_router" {
backend = "local"
config = {
path = "../main_net_dns_router/terraform.tfstate"
}
}
module "labs_common_variables" {
source = "../../modules/labs_common_variables"
}
module "ssh_settings" {
source = "../../modules/ssh-key-ref"
}
locals {
vm_count = 14
dns_zone = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone
dns_zone_id = data.terraform_remote_state.privnet_dns_router.outputs.dns_zone_id
main_private_network_id = data.terraform_remote_state.privnet_dns_router.outputs.main_private_network_id
main_private_subnet_id = data.terraform_remote_state.privnet_dns_router.outputs.main_subnet_network_id
floating_ip_pool = data.terraform_remote_state.privnet_dns_router.outputs.floating_ip_pools.main_public_ip_pool
availability_zone = module.labs_common_variables.availability_zones_names.availability_zone_no_gpu
default_sg_name = module.labs_common_variables.default_security_group_name
}
# Look up the default security group by name, scoped to the infrascience project
data "openstack_networking_secgroup_v2" "default" {
name = local.default_sg_name
tenant_id = "3511cd5293dc435ea421aeb0edcfab43"
}
# --- Security group: SSH from anywhere ---
resource "openstack_networking_secgroup_v2" "ssh_from_anywhere" {
name = "corso-k8s-ssh-from-anywhere"
description = "Allow SSH access from anywhere"
delete_default_rules = true
}
resource "openstack_networking_secgroup_rule_v2" "ssh_from_anywhere_ingress" {
security_group_id = openstack_networking_secgroup_v2.ssh_from_anywhere.id
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 22
port_range_max = 22
remote_ip_prefix = "0.0.0.0/0"
}
# --- Network ports ---
resource "openstack_networking_port_v2" "corso_k8s_port" {
count = local.vm_count
name = format("corso-k8s-%02d-port", count.index + 1)
admin_state_up = true
network_id = local.main_private_network_id
security_group_ids = [
data.openstack_networking_secgroup_v2.default.id,
openstack_networking_secgroup_v2.ssh_from_anywhere.id,
]
fixed_ip {
subnet_id = local.main_private_subnet_id
}
}
# --- Data volumes (200 GB each) ---
resource "openstack_blockstorage_volume_v3" "corso_k8s_data_vol" {
count = local.vm_count
name = format("corso-k8s-%02d-data", count.index + 1)
size = 200
enable_online_resize = true
}
# --- Compute instances ---
resource "openstack_compute_instance_v2" "corso_k8s" {
count = local.vm_count
name = format("corso-k8s-%02d", count.index + 1)
availability_zone_hints = local.availability_zone
flavor_name = "m1.large"
key_pair = module.ssh_settings.ssh_key_name
block_device {
uuid = module.labs_common_variables.ubuntu_2404.uuid
source_type = "image"
volume_size = 100
boot_index = 0
destination_type = "volume"
delete_on_termination = false
}
network {
port = openstack_networking_port_v2.corso_k8s_port[count.index].id
}
user_data = file("${module.labs_common_variables.ubuntu2404_data_file}")
lifecycle {
ignore_changes = [
key_pair, user_data, network
]
}
}
# --- Attach data volumes ---
resource "openstack_compute_volume_attach_v2" "corso_k8s_data_vol_attach" {
count = local.vm_count
instance_id = openstack_compute_instance_v2.corso_k8s[count.index].id
volume_id = openstack_blockstorage_volume_v3.corso_k8s_data_vol[count.index].id
device = "/dev/vdb"
}
# --- Floating IPs ---
resource "openstack_networking_floatingip_v2" "corso_k8s_ip" {
count = local.vm_count
pool = local.floating_ip_pool
description = format("Public IP for corso-k8s-%02d", count.index + 1)
}
resource "openstack_networking_floatingip_associate_v2" "corso_k8s_ip" {
count = local.vm_count
floating_ip = openstack_networking_floatingip_v2.corso_k8s_ip[count.index].address
port_id = openstack_networking_port_v2.corso_k8s_port[count.index].id
}
# --- DNS records ---
resource "openstack_dns_recordset_v2" "corso_k8s_dns" {
count = local.vm_count
zone_id = local.dns_zone_id
name = format("corso-k8s-%02d.%s", count.index + 1, local.dns_zone.name)
description = format("Public IP of corso-k8s-%02d", count.index + 1)
ttl = 8600
type = "A"
records = [openstack_networking_floatingip_v2.corso_k8s_ip[count.index].address]
}

View File

@ -1,19 +0,0 @@
output "corso_k8s_instances" {
description = "Instance IDs of the corso-k8s VMs"
value = openstack_compute_instance_v2.corso_k8s[*].id
}
output "corso_k8s_public_ips" {
description = "Floating IP addresses of the corso-k8s VMs"
value = openstack_networking_floatingip_v2.corso_k8s_ip[*].address
}
output "corso_k8s_hostnames" {
description = "DNS hostnames of the corso-k8s VMs"
value = openstack_dns_recordset_v2.corso_k8s_dns[*].name
}
output "corso_k8s_private_ips" {
description = "Private IP addresses of the corso-k8s VMs"
value = openstack_networking_port_v2.corso_k8s_port[*].all_fixed_ips
}

View File

@ -1,14 +0,0 @@
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = ">= 2.0.0"
}
}
}
provider "openstack" {
cloud = "infrascience"
}

File diff suppressed because it is too large Load Diff