Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway API v1.0 #2474

Open
mans0954 opened this issue Apr 22, 2024 · 4 comments
Open

Gateway API v1.0 #2474

mans0954 opened this issue Apr 22, 2024 · 4 comments
Assignees

Comments

@mans0954
Copy link

mans0954 commented Apr 22, 2024

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

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
@BBBmau BBBmau self-assigned this Aug 15, 2024
@BBBmau
Copy link
Contributor

BBBmau commented Sep 19, 2024

@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?

@mans0954
Copy link
Author

mans0954 commented Sep 20, 2024

@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?

@BBBmau
Copy link
Contributor

BBBmau commented Oct 10, 2024

@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.

@mans0954
Copy link
Author

@BBBmau thanks - that's useful to know in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants