Creating VKE cluster in a private VPC
Some checks failed
Ansible Linting / ansible-lint (push) Failing after 5s
Secops Linting and Safety Checks / checkov-scan-s3 (push) Failing after 18s

This commit is contained in:
shockrah 2025-06-04 23:29:26 -07:00
parent 1281ea8857
commit 9c2e0a84d7
4 changed files with 8 additions and 87 deletions

View File

@ -1,62 +0,0 @@
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"
}
}

View File

@ -1,7 +1,8 @@
resource vultr_kubernetes athens {
region = var.cluster.region
region = var.cluster.region
version = var.cluster.version
label = var.cluster.label
label = var.cluster.label
vpc_id = vultr_vpc.athens.id
node_pools {
node_quantity = var.cluster.pools["main"].min_nodes

View File

@ -6,26 +6,4 @@ resource vultr_firewall_rule web_inbound {
subnet = "0.0.0.0"
subnet_size = 0
port = each.value
}
resource vultr_firewall_rule game-server-inbound {
for_each = var.game_servers.configs
firewall_group_id = vultr_kubernetes.athens.firewall_group_id
protocol = "tcp"
ip_type = "v4"
subnet = "0.0.0.0"
subnet_size = 0
port = each.value.port.expose
}
resource vultr_firewall_rule admin-service-inbound {
for_each = var.admin_services.configs
firewall_group_id = vultr_kubernetes.athens.firewall_group_id
protocol = "tcp"
ip_type = "v4"
subnet = "0.0.0.0"
subnet_size = 0
notes = each.value.port.notes
port = each.value.port.expose
}
}

View File

@ -0,0 +1,4 @@
resource vultr_vpc athens {
description = "Private VPC for private and personal service projects"
region = var.cluster.region
}