Description
Ingress reachability depends on the controller, endpoint and network settings. Check the backend Service name and port separately.
Potential impact
A wrong route can break the connection or send external traffic to an internal service.
Remediation
Keep internal services behind private controllers or endpoints. Configure authentication and TLS on public routes. Test the Ingress route and the Service’s NodePort separately from outside the cluster.
Examples
For Kubernetes 1.22 and later, use kubernetes_ingress_v1. These excerpts use legacy syntax. Configure controller-specific path handling and Service backends separately.
Before
resource "kubernetes_service" "example" {
metadata {
name = "ingress-service"
}
spec {
port {
port = 80
target_port = 80
protocol = "TCP"
}
type = "NodePort"
}
}
resource "kubernetes_ingress" "example" {
metadata {
name = "example"
}
spec {
rule {
http {
path {
path = "/*"
backend {
service_name = "example"
service_port = 80
}
}
}
}
}
}
After
resource "kubernetes_service" "example" {
metadata {
name = "ingress-service"
}
spec {
port {
port = 80
target_port = 80
protocol = "TCP"
}
type = "NodePort"
}
}
resource "kubernetes_ingress" "example" {
metadata {
name = "example"
}
spec {
rule {
http {
path {
path = "/*"
backend {
service_name = kubernetes_service.example.metadata.0.name
service_port = 80
}
}
}
}
}
}
Referencing ingress-service fixes the mismatch with the literal backend name example. Both versions still use NodePort and omit the Service selector, so you must supply backend endpoints.