feat: add system and customer node pools, scale default workers to 0
This commit is contained in:
@@ -5,17 +5,39 @@ resource "digitalocean_kubernetes_cluster" "main" {
|
|||||||
region = var.region
|
region = var.region
|
||||||
version = var.k8s_version
|
version = var.k8s_version
|
||||||
|
|
||||||
|
# Default pool — scaled to 0, workloads run on system/customer pools
|
||||||
node_pool {
|
node_pool {
|
||||||
name = "workers"
|
name = "workers"
|
||||||
size = var.k8s_node_size
|
size = "s-2vcpu-4gb"
|
||||||
min_nodes = var.k8s_min_nodes
|
node_count = 0
|
||||||
max_nodes = var.k8s_max_nodes
|
|
||||||
auto_scale = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tags = ["lunarfront", "k8s"]
|
tags = ["lunarfront", "k8s"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Customer pool — auto-scales for customer app instances
|
||||||
|
resource "digitalocean_kubernetes_node_pool" "system" {
|
||||||
|
cluster_id = digitalocean_kubernetes_cluster.main.id
|
||||||
|
name = "system"
|
||||||
|
size = var.k8s_system_node_size
|
||||||
|
node_count = 2
|
||||||
|
labels = {
|
||||||
|
role = "system"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "digitalocean_kubernetes_node_pool" "customers" {
|
||||||
|
cluster_id = digitalocean_kubernetes_cluster.main.id
|
||||||
|
name = "customers"
|
||||||
|
size = var.k8s_customer_node_size
|
||||||
|
min_nodes = 0
|
||||||
|
max_nodes = var.k8s_max_customer_nodes
|
||||||
|
auto_scale = true
|
||||||
|
labels = {
|
||||||
|
role = "customer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ─── DNS — wildcard for customer subdomains → cluster load balancer ───────────
|
# ─── DNS — wildcard for customer subdomains → cluster load balancer ───────────
|
||||||
# Uncomment after the cluster is up and nginx ingress load balancer IP is known.
|
# Uncomment after the cluster is up and nginx ingress load balancer IP is known.
|
||||||
# Set cluster_lb_ip in terraform.tfvars then re-run terraform apply.
|
# Set cluster_lb_ip in terraform.tfvars then re-run terraform apply.
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ resource "cloudflare_record" "gitea" {
|
|||||||
name = "git"
|
name = "git"
|
||||||
type = "A"
|
type = "A"
|
||||||
content = var.cluster_lb_ip
|
content = var.cluster_lb_ip
|
||||||
proxied = true
|
proxied = false
|
||||||
ttl = 1
|
ttl = 3600
|
||||||
}
|
}
|
||||||
|
|
||||||
# DNS only — no Cloudflare proxy, for SSH git access
|
# DNS only — no Cloudflare proxy, for SSH git access
|
||||||
|
|||||||
@@ -46,22 +46,22 @@ variable "k8s_version" {
|
|||||||
default = "1.32.13-do.2"
|
default = "1.32.13-do.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "k8s_node_size" {
|
variable "k8s_system_node_size" {
|
||||||
description = "Node pool droplet size"
|
description = "System node pool droplet size (infra workloads)"
|
||||||
type = string
|
type = string
|
||||||
default = "s-2vcpu-4gb"
|
default = "s-2vcpu-4gb"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "k8s_min_nodes" {
|
variable "k8s_customer_node_size" {
|
||||||
description = "Minimum nodes in the pool"
|
description = "Customer node pool droplet size (app instances)"
|
||||||
type = number
|
type = string
|
||||||
default = 1
|
default = "s-1vcpu-2gb"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "k8s_max_nodes" {
|
variable "k8s_max_customer_nodes" {
|
||||||
description = "Maximum nodes in the pool"
|
description = "Maximum nodes in the customer pool"
|
||||||
type = number
|
type = number
|
||||||
default = 3
|
default = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "cluster_lb_ip" {
|
variable "cluster_lb_ip" {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ resource "cloudflare_ruleset" "admin_ip_allowlist" {
|
|||||||
expression = <<-EOT
|
expression = <<-EOT
|
||||||
(
|
(
|
||||||
http.host in {
|
http.host in {
|
||||||
"git.${var.domain}"
|
|
||||||
"vault.${var.domain}"
|
"vault.${var.domain}"
|
||||||
"argocd.${var.domain}"
|
"argocd.${var.domain}"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user