kubernetes-init/main.tf

150 lines
3.5 KiB
Terraform
Raw Permalink Normal View History

2022-06-04 14:07:06 +02:00
terraform {
required_version = ">= 1.2.0"
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = ">= 1.0.0"
}
}
}
provider "hcloud" {
token = var.hcloud_token
}
2022-05-08 14:55:59 +02:00
module "kube-hetzner" {
2022-06-04 14:07:06 +02:00
providers = {
hcloud = hcloud
}
2022-05-08 15:51:41 +02:00
source = "kube-hetzner/kube-hetzner/hcloud"
hcloud_token = var.hcloud_token
2022-06-04 14:07:06 +02:00
ssh_public_key = file(".keys/id_ed25519.pub")
ssh_private_key = file(".keys/id_ed25519")
2022-05-08 15:51:41 +02:00
network_region = "eu-central" # change to `us-east` if location is ash
control_plane_nodepools = [
{
name = "control-plane-fsn1",
server_type = "cpx11",
location = "fsn1",
labels = [],
taints = [],
count = 1
},
{
name = "control-plane-nbg1",
server_type = "cpx11",
location = "nbg1",
labels = [],
taints = [],
count = 1
},
{
name = "control-plane-hel1",
server_type = "cpx11",
location = "hel1",
labels = [],
taints = [],
count = 1
}
]
agent_nodepools = [
{
name = "agent-small1",
server_type = "cpx11",
location = "fsn1",
labels = [],
taints = [],
count = 1
},
{
name = "agent-small2",
server_type = "cpx11",
location = "nbg1",
labels = [],
taints = [],
2022-06-04 14:07:06 +02:00
count = 0
2022-05-08 15:51:41 +02:00
},
{
name = "storage1",
server_type = "cpx11",
location = "fsn1",
labels = [
"node.kubernetes.io/server-usage=storage"
],
taints = [
"server-usage=storage:NoSchedule"
],
2022-06-04 14:07:06 +02:00
count = 1
2022-05-08 15:51:41 +02:00
}
]
load_balancer_type = "lb11"
load_balancer_location = "fsn1"
traefik_enabled = true
2022-06-04 14:07:06 +02:00
traefik_additional_options = ["--log.level=DEBUG", "--tracing=true"]
2022-05-08 15:51:41 +02:00
metrics_server_enabled = true
automatically_upgrade_k3s = true
initial_k3s_channel = "stable"
cluster_name = "clank"
use_cluster_name_in_node_name = true
# Adding extra firewall rules, like opening a port
# More info on the format here https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/firewall
2022-05-08 20:27:01 +02:00
extra_firewall_rules = [
# # For Postgres
# {
# direction = "in"
# protocol = "tcp"
# port = "5432"
# source_ips = ["0.0.0.0/0", "::/0"]
# destination_ips = [] # Won't be used for this rule
# },
# # To Allow ArgoCD access to resources via SSH
{
direction = "out"
protocol = "tcp"
port = "22"
source_ips = [] # Won't be used for this rule
destination_ips = ["0.0.0.0/0", "::/0"]
}
]
2022-05-08 15:51:41 +02:00
2022-06-04 14:07:06 +02:00
enable_cert_manager = false
2022-05-08 15:51:41 +02:00
}
2022-05-08 14:55:59 +02:00
2022-05-08 15:51:41 +02:00
module "dns" {
source = "./modules/cloudflare"
api_token = var.cloudflare_api_token
zone_id = "9454b35cb1010b9eab9aadf206fdf11f"
records = [
{
name = "kjuulh.app",
ip = module.kube-hetzner.load_balancer_public_ipv4
ip_type = "A"
},
{
name = "*.kjuulh.app",
ip = module.kube-hetzner.load_balancer_public_ipv4
ip_type = "A"
}
]
2022-05-08 14:55:59 +02:00
}
2022-05-08 17:02:47 +02:00
2022-06-04 14:07:06 +02:00
#module "flux" {
# source = "./modules/flux"
# path = "clank"
# namespace = "flux-system"
# url = "ssh://git@git.front.kjuulh.io/clank/kubernetes-state.git"
# branch = "main"
#
# ssh_private_key_pem = file(".keys/id_clank")
# ssh_public_key_pem = file(".keys/id_clank.pub")
#}