diff --git a/terraform/.terraform/modules/modules.json b/terraform/.terraform/modules/modules.json index f2fd9af..5bb1855 100644 --- a/terraform/.terraform/modules/modules.json +++ b/terraform/.terraform/modules/modules.json @@ -1 +1 @@ -{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"api_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"argocd_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"drone_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"gitea_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"grafana_k8s_monitoring_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"helm-repo_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"keycloak_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"monitoring_cluster","Source":"./modules/k8s-cluster","Dir":"modules/k8s-cluster"},{"Key":"nextcloud_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"personal_website_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"prometheus_k8s_test_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"statping_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"test_cluster","Source":"./modules/k8s-cluster","Dir":"modules/k8s-cluster"},{"Key":"thanos_prometheus_k8s_test_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"wahlrecht_domain","Source":"./modules/domain","Dir":"modules/domain"}]} \ No newline at end of file +{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"api_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"argocd_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"drone_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"gitea_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"grafana_k8s_monitoring_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"helm-repo_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"keycloak_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"monitoring_cluster","Source":"./modules/k8s-cluster","Dir":"modules/k8s-cluster"},{"Key":"nextcloud_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"personal_website_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"prometheus_k8s_test_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"statping_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"test_cluster","Source":"./modules/k8s-cluster","Dir":"modules/k8s-cluster"},{"Key":"test_swarm_cluster","Source":"./modules/docker-network","Dir":"modules/docker-network"},{"Key":"thanos_prometheus_k8s_test_domain","Source":"./modules/domain","Dir":"modules/domain"},{"Key":"wahlrecht_domain","Source":"./modules/domain","Dir":"modules/domain"}]} \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index d99c294..6b4a22d 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -40,7 +40,7 @@ module "test_cluster" { name = data.hcloud_location.falkenstein.name, datacenter_name = data.hcloud_datacenter.falkenstein.name, network_zone = data.hcloud_location.falkenstein.network_zone - }, { + }, { id = data.hcloud_location.nuremberg.id, name = data.hcloud_location.nuremberg.name, datacenter_name = data.hcloud_datacenter.nuremberg.name, @@ -61,12 +61,12 @@ module "test_cluster" { server_type = "cax21" image_name = "ubuntu-22.04" create_loadbalancer = false - loadbalancer_ip = cidrhost(hcloud_network_subnet.k8s-network-subnet.ip_range, 3) + loadbalancer_ip = cidrhost(hcloud_network_subnet.k8s-network-subnet.ip_range, 3) vault_service_principal = { client_id : var.vault_client_id client_secret : var.vault_client_secret } - vault_allowed_namespaces = ["wahlrecht", "timetable", "hcloud", "routing"] + vault_allowed_namespaces = ["wahlrecht", "timetable", "hcloud", "routing"] hcloud_token_enabled = false hcloud_token = var.hcloud_token thanos_enabled = true @@ -93,7 +93,7 @@ module "monitoring_cluster" { name = data.hcloud_location.falkenstein.name, datacenter_name = data.hcloud_datacenter.falkenstein.name, network_zone = data.hcloud_location.falkenstein.network_zone - }, { + }, { id = data.hcloud_location.nuremberg.id, name = data.hcloud_location.nuremberg.name, datacenter_name = data.hcloud_datacenter.nuremberg.name, @@ -112,12 +112,12 @@ module "monitoring_cluster" { server_type = "cax21" image_name = "ubuntu-22.04" create_loadbalancer = false - loadbalancer_ip = cidrhost(hcloud_network_subnet.k8s-network-subnet.ip_range, 3) + loadbalancer_ip = cidrhost(hcloud_network_subnet.k8s-network-subnet.ip_range, 3) vault_service_principal = { client_id : var.vault_client_id client_secret : var.vault_client_secret } - vault_allowed_namespaces = ["hcloud"] + vault_allowed_namespaces = ["hcloud"] hcloud_token_enabled = false hcloud_token = var.hcloud_token thanos_enabled = true @@ -126,4 +126,37 @@ module "monitoring_cluster" { aws_secret_key = var.aws_secret_key argocd_keycloak_client_secret = var.argocd_monitoring_keycloak_client_secret argocd_domain = "argocd.k8s.monitoring.2martens.de" -} \ No newline at end of file +} + +module "test_swarm_cluster" { + source = "./modules/docker-network" + + admin_ssh_key = data.hcloud_ssh_key.macos + admin_user = "2martensAdmin" + terraform_public_ssh_key = var.terraform_public_ssh_key + terraform_private_ssh_key = var.terraform_private_ssh_key + basic_firewall_id = hcloud_firewall.basic-firewall.id + domain = local.domain + locations = [ + { + id = data.hcloud_location.falkenstein.id, + name = data.hcloud_location.falkenstein.name, + datacenter_name = data.hcloud_datacenter.falkenstein.name, + network_zone = data.hcloud_location.falkenstein.network_zone + }, { + id = data.hcloud_location.nuremberg.id, + name = data.hcloud_location.nuremberg.name, + datacenter_name = data.hcloud_datacenter.nuremberg.name, + network_zone = data.hcloud_location.nuremberg.network_zone + } + ] + network_id = hcloud_network.kubernetes-network.id + private_node_ips = [ + cidrhost(hcloud_network_subnet.k8s-network-subnet.ip_range, 10), + cidrhost(hcloud_network_subnet.k8s-network-subnet.ip_range, 11), + cidrhost(hcloud_network_subnet.k8s-network-subnet.ip_range, 12) + ] + server_subnet_id = hcloud_network_subnet.k8s-network-subnet.id + stage_name = local.test_cluster + number_nodes = 2 +} diff --git a/terraform/modules/docker-network/swarm-node.tf b/terraform/modules/docker-network/swarm-node.tf index 2553f2e..551701d 100644 --- a/terraform/modules/docker-network/swarm-node.tf +++ b/terraform/modules/docker-network/swarm-node.tf @@ -61,7 +61,7 @@ resource "hcloud_server" "node" { ignore_remote_firewall_ids = false keep_disk = false placement_group_id = data.hcloud_placement_group.default.id - firewall_ids = [var.basic_firewall_id, var.docker_firewall_id] + firewall_ids = [var.basic_firewall_id] ssh_keys = [var.admin_ssh_key.id] shutdown_before_deletion = true diff --git a/terraform/modules/docker-network/variables.tf b/terraform/modules/docker-network/variables.tf index ba62478..02f24d7 100644 --- a/terraform/modules/docker-network/variables.tf +++ b/terraform/modules/docker-network/variables.tf @@ -58,11 +58,6 @@ variable "basic_firewall_id" { type = number } -variable "docker_firewall_id" { - description = "ID of the docker specific firewall" - type = number -} - variable "stage_name" { description = "The name of the stage. For example test, qs, prod. Will be used for names and subdomains and must be unique within the Hetzner project (identified by API token)." type = string