separating game and admin service node pools with pods and what not
Some checks failed
Ansible Linting / ansible-lint (push) Failing after 3s
Secops Linting and Safety Checks / checkov-scan-s3 (push) Failing after 14s

This commit is contained in:
shockrah 2024-12-19 01:28:44 -08:00
parent ac11487feb
commit f2c4506245
5 changed files with 55 additions and 33 deletions

View File

@ -1,4 +1,5 @@
resource kubernetes_namespace admin-servers { resource kubernetes_namespace admin-servers {
count = length(var.admin_services.configs) > 0 ? 1 : 0
metadata { metadata {
name = var.admin_services.namespace name = var.admin_services.namespace
} }
@ -15,6 +16,9 @@ resource kubernetes_pod admin {
} }
} }
spec { spec {
node_selector = {
NodeType = var.admin_services.namespace
}
container { container {
image = each.value.image image = each.value.image
name = coalesce(each.value.name, each.key) name = coalesce(each.value.name, each.key)

View File

@ -6,15 +6,25 @@ resource vultr_kubernetes athens {
# once the cluster is up, we should comment this out again # once the cluster is up, we should comment this out again
# enable_firewall = true # enable_firewall = true
node_pools { node_pools {
# how many nodes do we want in this pool
node_quantity = 1 node_quantity = 1
plan = var.cluster.metapool.plan plan = var.cluster.pools["meta"].plan
label = var.cluster.label label = var.admin_services.namespace
min_nodes = var.cluster.metapool.min min_nodes = var.cluster.pools["meta"].min
max_nodes = var.cluster.metapool.max max_nodes = var.cluster.pools["meta"].max
# tag = var.admin_services.namespace
} }
} }
resource vultr_kubernetes_node_pools games {
cluster_id = vultr_kubernetes.athens.id
node_quantity = var.cluster.pools["games"].min
plan = var.cluster.pools["games"].plan
label = var.game_servers.namespace
min_nodes = var.cluster.pools["games"].min
max_nodes = var.cluster.pools["games"].max
tag = var.admin_services.namespace
}
output k8s_config { output k8s_config {
value = vultr_kubernetes.athens.kube_config value = vultr_kubernetes.athens.kube_config
sensitive = true sensitive = true

View File

@ -1,4 +1,5 @@
resource kubernetes_namespace game-servers { resource kubernetes_namespace game-servers {
count = length(var.game_servers.configs) > 0 ? 1 : 0
metadata { metadata {
name = var.game_servers.namespace name = var.game_servers.namespace
} }

View File

@ -25,12 +25,12 @@ variable cluster {
region = string region = string
label = string label = string
version = string version = string
metapool = object({ pools = map(object({
plan = string plan = string
autoscale = bool autoscale = bool
min = number min = number
max = number max = number
}) }))
}) })
} }
@ -38,17 +38,16 @@ variable game_servers {
type = object({ type = object({
namespace = string namespace = string
configs = map(object({ configs = map(object({
name = optional(string) name = optional(string)
image = string image = string
cpu = string cpu = string
mem = string mem = string
port = object({ port = object({
internal = number internal = number
expose = number expose = number
})
proto = optional(string)
}) })
) proto = optional(string)
}))
}) })
} }

View File

@ -2,11 +2,19 @@ cluster = {
region = "lax" region = "lax"
label = "athens-cluster" label = "athens-cluster"
version = "v1.31.2+1" version = "v1.31.2+1"
metapool = { pools = {
plan = "vc2-1c-2gb" meta = {
autoscale = true plan = "vc2-1c-2gb"
min = 1 autoscale = true
max = 2 min = 1
max = 2
}
games = {
plan = "vc2-1c-2gb"
autoscale = true
min = 1
max = 3
}
} }
} }
@ -28,16 +36,16 @@ game_servers = {
admin_services = { admin_services = {
namespace = "admin-services" namespace = "admin-services"
configs = { configs = {
health = { # health = {
image = "nginx:latest" # image = "nginx:latest"
name = "health" # name = "health"
cpu = "200m" # cpu = "200m"
mem = "64Mi" # mem = "64Mi"
port = { # port = {
notes = "Basic nginx sanity check service" # notes = "Basic nginx sanity check service"
expose = 30800 # expose = 30800
internal = 80 # internal = 80
} # }
} # }
} }
} }