Example nodeport based service now done

This commit is contained in:
shockrah 2024-12-08 15:54:14 -08:00
parent 52e8c56682
commit abf3297498
2 changed files with 73 additions and 0 deletions

View File

@ -7,3 +7,12 @@ resource vultr_firewall_rule web_inbound {
subnet_size = 0
port = each.value
}
resource vultr_firewall_rule web-health-inbound {
firewall_group_id = vultr_kubernetes.athens.firewall_group_id
protocol = "tcp"
ip_type = "v4"
subnet = "0.0.0.0"
subnet_size = 0
port = local.sanity.port
}

View File

@ -0,0 +1,64 @@
# Here we create a super simple pod that we can reach via IP
# Using nginx as the service to expose
locals {
sanity = {
namespace = "sanity"
service = "web-health"
port = 30808
}
}
resource kubernetes_namespace sanity {
metadata {
name = local.sanity.namespace
}
}
resource kubernetes_pod nginx {
metadata {
name = local.sanity.service
labels = {
app = local.sanity.service
}
}
spec {
container {
image = "nginx:latest"
name = "nginx"
resources {
limits = {
cpu = "200m"
memory = "64Mi"
}
}
liveness_probe {
http_get {
path = "/"
port = 80
}
initial_delay_seconds = 30
period_seconds = 30
}
}
}
}
resource kubernetes_service nginx {
metadata {
name = local.sanity.service
}
spec {
selector = {
app = local.sanity.service
}
port {
port = 8080
target_port = 80
node_port = local.sanity.port
}
type = "NodePort"
}
}