53 lines
1.2 KiB
HCL
53 lines
1.2 KiB
HCL
resource kubernetes_namespace game-servers {
|
|
metadata {
|
|
name = var.game_servers.namespace
|
|
}
|
|
}
|
|
|
|
resource kubernetes_pod game {
|
|
for_each = var.game_servers.configs
|
|
|
|
metadata {
|
|
name = each.key
|
|
namespace = var.game_servers.namespace
|
|
labels = {
|
|
app = each.key
|
|
}
|
|
}
|
|
spec {
|
|
container {
|
|
image = each.value.image
|
|
name = coalesce(each.value.name, each.key)
|
|
resources {
|
|
limits = {
|
|
cpu = each.value.cpu
|
|
memory = each.value.mem
|
|
}
|
|
}
|
|
port {
|
|
container_port = each.value.port
|
|
protocol = coalesce(each.value.proto, "TCP")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
resource kubernetes_service game {
|
|
for_each = var.game_servers.configs
|
|
metadata {
|
|
name = each.key
|
|
namespace = var.game_servers.namespace
|
|
}
|
|
spec {
|
|
selector = {
|
|
app = each.key
|
|
}
|
|
port {
|
|
target_port = each.value.port
|
|
port = each.value.port
|
|
node_port = each.value.port
|
|
}
|
|
type = "NodePort"
|
|
}
|
|
}
|