63 lines
1.6 KiB
HCL
63 lines
1.6 KiB
HCL
resource kubernetes_namespace admin-servers {
|
|
count = length(var.admin_services.configs) > 0 ? 1 : 0
|
|
metadata {
|
|
name = var.admin_services.namespace
|
|
}
|
|
}
|
|
|
|
resource kubernetes_pod admin {
|
|
for_each = var.admin_services.configs
|
|
|
|
metadata {
|
|
name = each.key
|
|
namespace = var.admin_services.namespace
|
|
labels = {
|
|
app = each.key
|
|
}
|
|
}
|
|
spec {
|
|
node_selector = {
|
|
"vke.vultr.com/node-pool" = var.admin_services.namespace
|
|
}
|
|
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.internal
|
|
protocol = coalesce(each.value.proto, "TCP")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
resource kubernetes_service admin {
|
|
for_each = var.admin_services.configs
|
|
metadata {
|
|
name = each.key
|
|
namespace = var.admin_services.namespace
|
|
labels = {
|
|
app = each.key
|
|
}
|
|
}
|
|
# TODO: don't make these NodePorts since we're gonna want them
|
|
# to be purely internal to the Cluster.
|
|
# WHY? Because we want to keep dashboards as unexposed as possible
|
|
spec {
|
|
selector = {
|
|
app = each.key
|
|
}
|
|
port {
|
|
target_port = each.value.port.internal
|
|
port = each.value.port.expose
|
|
}
|
|
type = "NodePort"
|
|
}
|
|
}
|
|
|