terraform-provider-kubernetes
terraform-provider-kubernetes copied to clipboard
Gateway API v1.0
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
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.
References
- https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io%2fv1
- https://kubernetes.io/blog/2023/10/31/gateway-api-ga/
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
@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.