Exposing sample 'game' port correctly now
Some checks failed
Ansible Linting / ansible-lint (push) Failing after 2s
Secops Linting and Safety Checks / checkov-scan-s3 (push) Failing after 14s

This commit is contained in:
shockrah 2024-12-10 18:00:26 -08:00
parent 5d03f6b218
commit f9c73b1e4a
4 changed files with 15 additions and 7 deletions

View File

@ -15,5 +15,5 @@ resource vultr_firewall_rule game-server-inbound {
ip_type = "v4" ip_type = "v4"
subnet = "0.0.0.0" subnet = "0.0.0.0"
subnet_size = 0 subnet_size = 0
port = each.value.port port = each.value.port.expose
} }

View File

@ -25,7 +25,7 @@ resource kubernetes_pod game {
} }
} }
port { port {
container_port = each.value.port container_port = each.value.port.internal
protocol = coalesce(each.value.proto, "TCP") protocol = coalesce(each.value.proto, "TCP")
} }
} }
@ -37,15 +37,17 @@ resource kubernetes_service game {
metadata { metadata {
name = each.key name = each.key
namespace = var.game_servers.namespace namespace = var.game_servers.namespace
labels = {
app = each.key
}
} }
spec { spec {
selector = { selector = {
app = each.key app = each.key
} }
port { port {
target_port = each.value.port target_port = each.value.port.internal
port = each.value.port port = each.value.port.expose
node_port = each.value.port
} }
type = "NodePort" type = "NodePort"
} }

View File

@ -42,7 +42,10 @@ variable game_servers {
image = string image = string
cpu = string cpu = string
mem = string mem = string
port = number port = object({
internal = number
expose = number
})
proto = optional(string) proto = optional(string)
}) })
) )

View File

@ -17,7 +17,10 @@ game_servers = {
image = "nginx:latest" image = "nginx:latest"
cpu = "200m" cpu = "200m"
mem = "64Mi" mem = "64Mi"
port = 30808 port = {
expose = 30808
internal = 80
}
} }
} }
} }