Verified Commit 38af0403 authored by Hugo's avatar Hugo
Browse files

terraform init

parent 8a2295f5
.terraform
terraform.tfstate
terraform.tfstate.backup
terraform.tfstate.d
values.auto.tfvars
\ No newline at end of file
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/local" {
version = "2.1.0"
hashes = [
"h1:EYZdckuGU3n6APs97nS2LxZm3dDtGqyM4qaIvsmac8o=",
"zh:0f1ec65101fa35050978d483d6e8916664b7556800348456ff3d09454ac1eae2",
"zh:36e42ac19f5d68467aacf07e6adcf83c7486f2e5b5f4339e9671f68525fc87ab",
"zh:6db9db2a1819e77b1642ec3b5e95042b202aee8151a0256d289f2e141bf3ceb3",
"zh:719dfd97bb9ddce99f7d741260b8ece2682b363735c764cac83303f02386075a",
"zh:7598bb86e0378fd97eaa04638c1a4c75f960f62f69d3662e6d80ffa5a89847fe",
"zh:ad0a188b52517fec9eca393f1e2c9daea362b33ae2eb38a857b6b09949a727c1",
"zh:c46846c8df66a13fee6eff7dc5d528a7f868ae0dcf92d79deaac73cc297ed20c",
"zh:dc1a20a2eec12095d04bf6da5321f535351a594a636912361db20eb2a707ccc4",
"zh:e57ab4771a9d999401f6badd8b018558357d3cbdf3d33cc0c4f83e818ca8e94b",
"zh:ebdcde208072b4b0f8d305ebf2bfdc62c926e0717599dcf8ec2fd8c5845031c3",
"zh:ef34c52b68933bedd0868a13ccfd59ff1c820f299760b3c02e008dc95e2ece91",
]
}
provider "registry.terraform.io/hashicorp/template" {
version = "2.2.0"
hashes = [
"h1:94qn780bi1qjrbC3uQtjJh3Wkfwd5+tTtJHOb7KTg9w=",
"zh:01702196f0a0492ec07917db7aaa595843d8f171dc195f4c988d2ffca2a06386",
"zh:09aae3da826ba3d7df69efeb25d146a1de0d03e951d35019a0f80e4f58c89b53",
"zh:09ba83c0625b6fe0a954da6fbd0c355ac0b7f07f86c91a2a97849140fea49603",
"zh:0e3a6c8e16f17f19010accd0844187d524580d9fdb0731f675ffcf4afba03d16",
"zh:45f2c594b6f2f34ea663704cc72048b212fe7d16fb4cfd959365fa997228a776",
"zh:77ea3e5a0446784d77114b5e851c970a3dde1e08fa6de38210b8385d7605d451",
"zh:8a154388f3708e3df5a69122a23bdfaf760a523788a5081976b3d5616f7d30ae",
"zh:992843002f2db5a11e626b3fc23dc0c87ad3729b3b3cff08e32ffb3df97edbde",
"zh:ad906f4cebd3ec5e43d5cd6dc8f4c5c9cc3b33d2243c89c5fc18f97f7277b51d",
"zh:c979425ddb256511137ecd093e23283234da0154b7fa8b21c2687182d9aea8b2",
]
}
provider "registry.terraform.io/hetznercloud/hcloud" {
version = "1.26.0"
hashes = [
"h1:2LLe4UKLS7R+t+tQL1oOFLA8c8/rs3iCfT26LyiQcsk=",
"zh:03d7eb722a4ee25774949baace0125392060d0369d4cb9257d7d298ab6ece3ff",
"zh:0fed2e63ac4cb6fe6b2a5b6891abf973cb7c1716e487fbabc09216e0ec05e866",
"zh:1a84c8c1c8e2d6607de5aa09aa3f9254183cde75a5acc666cca5f4b02a1d290e",
"zh:23ac426aa3a0001fb20045dc35569978864f139732f45ab671c64e80123c91a1",
"zh:23b78348b24ae3e4679bd90989c999346efd71ee228d17368d5f556f63e5fd06",
"zh:2503fe28ac87661af96e7755a7404307000822104ac1abc571271eee46c95ab5",
"zh:3fe859b2611d20ed5cd65cc2ec812acf73c7dfb39f2fee45ef99a3896c2662a8",
"zh:51ef869ed35d0d8aada35f587c4a64802f1140dc93c40a4e7c9800560143bb1a",
"zh:69b93cf4adca465b89da08e4e3b4aaf831821f1fbae68e526c0a292b3cfa463d",
"zh:6a4e23c6aa86e3d30240e6e4c97daef3af9ad217be2c6f35300fe1839fdbf8b2",
"zh:97a513459692a981a62b4a566c1d736c4a67622d2fbbee3771ec3ea8d576d484",
"zh:fec6c07731e23d1dd45015b44747b89c4fee58b5b2560f96d24c7da5a8ecb2ad",
]
}
resource "hcloud_server" "controller" {
count = var.controller_count
name = "${var.cluster_name}-controller-${count.index}"
image = "debian-10"
server_type = var.controller_type
ssh_keys = var.ssh_keys
location = var.location
labels = {
cluster = var.cluster_name
role = "controller"
}
}
resource "hcloud_load_balancer" "control_plane_load_balancer" {
name = "${var.cluster_name}-control-plane"
load_balancer_type = var.control_plane_lb_type
location = var.location
labels = {
cluster = var.cluster_name
}
dynamic "target" {
for_each = hcloud_server.controller
content {
type = "server"
server_id = target.value["id"]
}
}
}
resource "hcloud_load_balancer_service" "control_plane_load_balancer_service" {
for_each = toset(var.control_plane_ports)
load_balancer_id = hcloud_load_balancer.control_plane_load_balancer.id
protocol = "tcp"
listen_port = each.value
destination_port = each.value
}
output "controller_ipv4" {
value = hcloud_server.controller.*.ipv4_address
}
output "worker_ipv4" {
value = hcloud_server.worker.*.ipv4_address
}
output "control_plane_ipv4" {
value = hcloud_load_balancer.control_plane_load_balancer.ipv4
}
output "ingress_ipv4" {
value = hcloud_load_balancer.ingress_load_balancer.ipv4
}
cluster_name = "ada-lovelace"
controller_count = 3
controller_type = "ccx12"
worker_count = 0
worker_type = "ccx22"
volume_count = 0
control_plane_lb_type = "lb11"
ingress_lb_type = "lb21"
\ No newline at end of file
provider "hcloud" {
token = var.hcloud_token
}
cluster_name = "ada-lovelace-testing"
controller_count = 3
controller_type = "cx11"
worker_count = 0
worker_type = "cx11"
volume_count = 2
control_plane_lb_type = "lb11"
ingress_lb_type = "lb11"
\ No newline at end of file
variable "hcloud_token" {
description = "Hetzner cloud auth token"
type = string
sensitive = true
}
variable "ssh_keys" {
description = "SSH Keys"
type = list(string)
}
variable "cluster_name" {
description = "Cluster name"
type = string
}
variable "location" {
description = "Cluster location"
type = string
default = "fsn1"
}
variable "controller_count" {
description = "Controller node count"
type = number
}
variable "controller_type" {
description = "Controller type"
type = string
}
variable "worker_count" {
description = "Worker node count"
type = number
}
variable "worker_type" {
description = "Node type"
type = string
}
variable "volume_count" {
description = "Number of columes by node"
type = number
}
variable "volume_size" {
description = "Volume size"
type = number
default = 10
}
variable "control_plane_ports" {
description = "Load balancer ports"
type = list(string)
default = ["6443", "9443", "8132", "8133"]
}
variable "ingress_ports" {
description = "Ingress ports"
type = list(string)
default = ["80", "443"]
}
variable "control_plane_lb_type" {
description = "Control plane load balancer type"
type = string
}
variable "ingress_lb_type" {
description = "Ingress load balancer type"
type = string
}
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
}
template = {
source = "hashicorp/template"
}
}
}
resource "hcloud_server" "worker" {
count = var.worker_count
name = "${var.cluster_name}-worker-${count.index}"
image = "debian-10"
server_type = var.worker_type
ssh_keys = var.ssh_keys
location = var.location
labels = {
cluster = var.cluster_name
role = "worker"
}
}
resource "hcloud_volume" "volume" {
count = var.volume_count * var.worker_count
name = "${var.cluster_name}-${count.index}"
size = var.volume_size
server_id = hcloud_server.worker[count.index % var.worker_count].id
depends_on = [hcloud_server.worker]
}
resource "hcloud_load_balancer" "ingress_load_balancer" {
name = "${var.cluster_name}-ingress"
load_balancer_type = var.ingress_lb_type
location = var.location
labels = {
cluster = var.cluster_name
}
dynamic "target" {
for_each = hcloud_server.worker
content {
type = "server"
server_id = target.value["id"]
}
}
}
resource "hcloud_load_balancer_service" "ingress_load_balancer_service" {
for_each = toset(var.ingress_ports)
load_balancer_id = hcloud_load_balancer.ingress_load_balancer.id
protocol = "tcp"
listen_port = each.value
destination_port = each.value
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment