Open mans0954 opened 7 months ago
@mans0954 I've taken this on and after looking into gateway api docs and playing around with it myself it seems like you can easily use the resourcs from the gateaway api with the help of the kubernetes_manifest
I implemented it both manually and through terraform, you can see my implementation of it in my repo here: BBBmau/gateway-api/terraform
Is their a reason for opening this issue when you could use the existing kubernetes_manifest
?
@BBBmau thank you for looking at this. In our current configuration we use kubernetes_ingress_v1
. Since gateways are the next generation of ingress I assumed that at some point there would be a kubernetes_gateway_v1
.
There's a lot of repetition in the definition of our ingress. With kubernetes_ingress_v1
we use terraform language features such as dynamic blocks to generate this e.g.:
dynamic "rule" {
for_each = local.languages
iterator = lang
content {
host = "${lang.value}.${var.domain}"
http {
path {
backend {
service {
name = "svc-${var.shortenv}"
port {
name = "svc-port"
}
}
}
path = "/socket/*"
path_type = "ImplementationSpecific"
}
path {
backend {
service {
name = "neg-svc-${var.shortenv}"
port {
name = "web-port"
}
}
}
path = "/spelling/*"
path_type = "ImplementationSpecific"
}
path {
backend {
service {
name = "web-neg-svc-${var.shortenv}"
port {
name = "web-port"
}
}
}
path = "/*"
path_type = "ImplementationSpecific"
}
}
}
}
I suspect trying to do something similar with kubernetes_manifest
would be less elegant?
@mans0954 you can actually still have Dynamic HTTPRoutes with manifest with the following tfconfig
:
locals {
rules = [
{
name = "echo"
port = 1027
path = "/echo"
},
{
name = "ping"
port = 1028
path = "/ping"
}
]
}
resource "kubernetes_manifest" "httproute_echo" {
manifest = {
"apiVersion" = "gateway.networking.k8s.io/v1"
"kind" = "HTTPRoute"
"metadata" = {
"name" = "echo"
"namespace" = "default"
}
"spec" = {
"parentRefs" = [
{
"group" = "gateway.networking.k8s.io"
"kind" = "Gateway"
"name" = "kong"
},
]
"rules" = [
for i, v in local.rules :
{
"backendRefs" = [
{
"name" = v.name
"port" = v.port
},
]
"matches" = [
{
"path" = {
"type" = "PathPrefix"
"value" = v.path
}
},
]
}
]
}
}
}
Though we understand the desire to have native gateway resources. We'll keep this issue open for future planning.
@BBBmau thanks - that's useful to know in the meantime.
Description
Are there any plans to support Gateway API now that it's [GA]?(https://kubernetes.io/blog/2023/10/31/gateway-api-ga/)
Potential Terraform Configuration
References
Community Note