|
|
|
terraform {
|
|
|
|
required_providers {
|
|
|
|
hcloud = {
|
|
|
|
source = "hetznercloud/hcloud"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
required_version = ">= 0.14"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "hcloud_token" {
|
|
|
|
sensitive = true
|
|
|
|
}
|
|
|
|
|
|
|
|
provider "hcloud" {
|
|
|
|
token = var.hcloud_token
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_network" "vnet" {
|
|
|
|
name = "cluster-vnet"
|
|
|
|
ip_range = "10.0.0.0/16"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_network_subnet" "vnet_subnet" {
|
|
|
|
network_id = hcloud_network.vnet.id
|
|
|
|
type = "cloud"
|
|
|
|
network_zone = "eu-central"
|
|
|
|
ip_range = "10.0.0.0/24"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_placement_group" "spread-group" {
|
|
|
|
name = "cluster-spread-group"
|
|
|
|
type = "spread"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_server" "control" {
|
|
|
|
name = "cluster-control"
|
|
|
|
image = "fedora-38"
|
|
|
|
location = "nbg1"
|
|
|
|
ssh_keys = ["archomen_cloud1", "deepthought_cloud1"]
|
|
|
|
server_type = "cx21"
|
|
|
|
firewall_ids = [hcloud_firewall.firewall.id]
|
|
|
|
placement_group_id = hcloud_placement_group.spread-group.id
|
|
|
|
|
|
|
|
public_net {
|
|
|
|
ipv4_enabled = true
|
|
|
|
ipv6_enabled = true
|
|
|
|
}
|
|
|
|
network {
|
|
|
|
network_id = hcloud_network.vnet.id
|
|
|
|
ip = "10.0.0.2"
|
|
|
|
}
|
|
|
|
|
|
|
|
depends_on = [
|
|
|
|
hcloud_network.vnet
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_server" "worker-1" {
|
|
|
|
name = "cluster-worker-1"
|
|
|
|
image = "fedora-38"
|
|
|
|
location = "nbg1"
|
|
|
|
ssh_keys = ["archomen_cloud2", "deepthought_cloud2"]
|
|
|
|
server_type = "cx21"
|
|
|
|
firewall_ids = [hcloud_firewall.firewall.id]
|
|
|
|
placement_group_id = hcloud_placement_group.spread-group.id
|
|
|
|
|
|
|
|
public_net {
|
|
|
|
ipv4_enabled = true
|
|
|
|
ipv6_enabled = true
|
|
|
|
}
|
|
|
|
network {
|
|
|
|
network_id = hcloud_network.vnet.id
|
|
|
|
ip = "10.0.0.3"
|
|
|
|
}
|
|
|
|
|
|
|
|
depends_on = [
|
|
|
|
hcloud_network.vnet
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_firewall" "firewall" {
|
|
|
|
name = "cluster-firewall"
|
|
|
|
## Inbound rules
|
|
|
|
rule {
|
|
|
|
direction = "in"
|
|
|
|
protocol = "icmp"
|
|
|
|
source_ips = [
|
|
|
|
"0.0.0.0/0",
|
|
|
|
"::/0"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
rule {
|
|
|
|
direction = "in"
|
|
|
|
protocol = "tcp"
|
|
|
|
port = "22"
|
|
|
|
source_ips = [
|
|
|
|
"0.0.0.0/0",
|
|
|
|
"::/0"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
rule {
|
|
|
|
direction = "in"
|
|
|
|
protocol = "tcp"
|
|
|
|
port = "80"
|
|
|
|
source_ips = [
|
|
|
|
"0.0.0.0/0",
|
|
|
|
"::/0"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
rule {
|
|
|
|
direction = "in"
|
|
|
|
protocol = "tcp"
|
|
|
|
port = "443"
|
|
|
|
source_ips = [
|
|
|
|
"0.0.0.0/0",
|
|
|
|
"::/0"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
rule {
|
|
|
|
direction = "in"
|
|
|
|
protocol = "tcp"
|
|
|
|
port = "6443"
|
|
|
|
source_ips = [
|
|
|
|
"0.0.0.0/0",
|
|
|
|
"::/0"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_load_balancer" "load_balancer" {
|
|
|
|
name = "cloud_lb"
|
|
|
|
load_balancer_type = "lb11"
|
|
|
|
location = "nbg1"
|
|
|
|
network_zone = "eu-central"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "hcloud_load_balancer_network" "srvnetwork" {
|
|
|
|
load_balancer_id = hcloud_load_balancer.load_balancer.id
|
|
|
|
network_id = hcloud_network.vnet.id
|
|
|
|
ip = "10.0.0.254"
|
|
|
|
}
|