Skip to content

feat: add Kubernetes Gateway API v1 resources and data sources#2863

Draft
Ret2Me wants to merge 3 commits intohashicorp:mainfrom
Ret2Me:main
Draft

feat: add Kubernetes Gateway API v1 resources and data sources#2863
Ret2Me wants to merge 3 commits intohashicorp:mainfrom
Ret2Me:main

Conversation

@Ret2Me
Copy link
Copy Markdown

@Ret2Me Ret2Me commented Apr 12, 2026


Rollback Plan

If a change needs to be reverted, we will publish an updated version of the library.

Changes to Security Controls

No changes to security controls. The new resources are read/write wrappers around
existing Kubernetes Gateway API objects and follow the same RBAC model as other
namespaced resources in this provider.

Description

Adds support for the Kubernetes Gateway API
(gateway.networking.k8s.io), which is the standard successor to the Ingress API
for managing L4/L7 traffic routing. All resources target the v1 API group
(sigs.k8s.io/gateway-api v1.5.1).

New resources and data sources:

  • kubernetes_gateway_class_v1 / data.kubernetes_gateway_class_v1
  • kubernetes_gateway_v1 / data.kubernetes_gateway_v1
  • kubernetes_http_route_v1 / data.kubernetes_http_route_v1
  • kubernetes_grpc_route_v1 / data.kubernetes_grpc_route_v1
  • kubernetes_tls_route_v1 / data.kubernetes_tls_route_v1
  • kubernetes_reference_grant_v1 / data.kubernetes_reference_grant_v1
  • kubernetes_backend_tls_policy_v1 / data.kubernetes_backend_tls_policy_v1
  • kubernetes_listener_set_v1 / data.kubernetes_listener_set_v1

Key features covered:

  • path/header/method/query matching
  • all HTTPRoute filter
  • types (CORS, RequestMirror, RequestRedirect, URLRewrite, header modifiers)
  • session persistence (Cookie with CookieConfig, Header)
  • retry with status codes
  • per-rule timeouts
  • weighted backend splits
  • TLS termination and passthrough
  • cross-namespace routing via ReferenceGrant, and BackendTLSPolicy with
    SubjectAltNames (Hostname and URI).

All resources support terraform import via namespace/name.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Tested against a KinD cluster with Gateway API CRDs installed:

kind create cluster --config=./.github/config/acceptance_tests_kind_config.yaml
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccKubernetesGatewayClassV1|TestAccKubernetesGatewayV1|TestAccKubernetesHTTPRouteV1|TestAccKubernetesGRPCRouteV1|TestAccKubernetesTLSRouteV1|TestAccKubernetesReferenceGrantV1|TestAccKubernetesBackendTLS
PolicyV1|TestAccKubernetesListenerSetV1|TestAccKubernetesGatewayAPI'

--- PASS: TestAccKubernetesGatewayClassV1_basic (3.91s)
--- PASS: TestAccKubernetesGatewayV1_basic (3.06s)
--- PASS: TestAccKubernetesHTTPRouteV1_basic (3.33s)
--- PASS: TestAccKubernetesHTTPRouteV1_complexFilters (9.14s)
--- PASS: TestAccKubernetesGRPCRouteV1_basic (3.65s)
--- PASS: TestAccKubernetesGRPCRouteV1_complex (8.21s)
--- PASS: TestAccKubernetesTLSRouteV1_basic (6.85s)
--- PASS: TestAccKubernetesReferenceGrantV1_basic (6.16s)
--- PASS: TestAccKubernetesBackendTLSPolicyV1_basic (6.69s)
--- PASS: TestAccKubernetesListenerSetV1_basic (6.90s)
--- PASS: TestAccKubernetesGatewayAPI_HTTPSRedirect (2.74s)
--- PASS: TestAccKubernetesGatewayAPI_CanaryDeployment (8.64s)
--- PASS: TestAccKubernetesGatewayAPI_PathBasedMicroservices (5.12s)
--- PASS: TestAccKubernetesGatewayAPI_GRPCRoutingAdvanced (2.45s)
--- PASS: TestAccKubernetesGatewayAPI_MultiTenantFull (10.98s)
--- PASS: TestAccKubernetesGatewayAPIStack_crossNamespace (10.93s)
ok    github.com/hashicorp/terraform-provider-kubernetes/kubernetes   42.31s

Release Note

FEATURES:

  • New resource: kubernetes_gateway_class_v1
  • New resource: kubernetes_gateway_v1
  • New resource: kubernetes_http_route_v1
  • New resource: kubernetes_grpc_route_v1
  • New resource: kubernetes_tls_route_v1
  • New resource: kubernetes_reference_grant_v1
  • New resource: kubernetes_backend_tls_policy_v1
  • New resource: kubernetes_listener_set_v1
  • New data source: kubernetes_gateway_class_v1
  • New data source: kubernetes_gateway_v1
  • New data source: kubernetes_http_route_v1
  • New data source: kubernetes_grpc_route_v1
  • New data source: kubernetes_tls_route_v1
  • New data source: kubernetes_reference_grant_v1
  • New data source: kubernetes_backend_tls_policy_v1
  • New data source: kubernetes_listener_set_v1

References


Note: Separately I've got a set of manual test configs (Terraform + kubectl script)
that verify all resources live including CORS, canaries, TLS passthrough, SANs
in BackendTLSPolicy, cross‑namespace routing, and more.

Happy to share if it helps with review or examples.

Closes: #2474

Implements resources and data sources for all Gateway API v1 types using
the gateway.networking.k8s.io API group (sigs.k8s.io/gateway-api v1.5.1).

New resources:
- kubernetes_gateway_class_v1
- kubernetes_gateway_v1 (listeners, TLS, addresses, infrastructure)
- kubernetes_http_route_v1 (matches, filters, session persistence, retry, timeouts)
- kubernetes_grpc_route_v1 (method/header matching, session persistence)
- kubernetes_tls_route_v1 (SNI passthrough and termination)
- kubernetes_reference_grant_v1 (cross-namespace routing grants)
- kubernetes_backend_tls_policy_v1 (TLS validation, SubjectAltNames)
- kubernetes_listener_set_v1 (experimental listener attachment)

Each resource ships with a matching read-only data source. All resources
support import via namespace/name. Provider registration updated in provider.go.
Dependencies added to go.mod/go.sum.
@Ret2Me Ret2Me requested a review from a team as a code owner April 12, 2026 00:23
@hashicorp-cla-app
Copy link
Copy Markdown

hashicorp-cla-app bot commented Apr 12, 2026

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@Ret2Me
Copy link
Copy Markdown
Author

Ret2Me commented Apr 12, 2026

Sorry for delivering everything as one commit. I realize that's messy.

The problem is the code is from an internal much bigger project repo, and I can't share the original commit history.
This "stash" was the only practical way to get you the current working version.

Thanks for your understanding and sorry again for the hassle.

@Ret2Me
Copy link
Copy Markdown
Author

Ret2Me commented Apr 12, 2026

Also, your Atlassian integration pipeline is broken, it's calling a deprecated endpoint.

API call GET /rest/api/3/search failed (410): The requested API has been removed. Please migrate to /rest/api/3/search/jql

@Ret2Me Ret2Me mentioned this pull request Apr 12, 2026
Ret2Me added 2 commits April 17, 2026 15:18
- Unit tests (gateway_flatten_expand_test.go): expand/flatten roundtrips
  for all 8 resource types covering nested structures, optional fields,
  and edge cases
- Per-resource acceptance tests covering basic CRUD, update, and import
- Cross-cutting tests (complex, realworld, service-mesh):
  multi-rule HTTPRoute with all filter types and update step,
  cross-namespace routing via ReferenceGrant, GRPCRoute method routing,
  TLS termination, CORS with session persistence, canary with RequestMirror,
  BackendTLSPolicy SubjectAltNames, API gateway pattern (redirect/retry/rewrite)
- Data source acceptance tests for all 7 data sources that lacked coverage
@Ret2Me Ret2Me changed the title feat: add Kubernetes Gateway API v1 resources and data sources draft: add Kubernetes Gateway API v1 resources and data sources Apr 18, 2026
@Ret2Me Ret2Me changed the title draft: add Kubernetes Gateway API v1 resources and data sources feat: add Kubernetes Gateway API v1 resources and data sources Apr 21, 2026
@Ret2Me Ret2Me marked this pull request as draft April 21, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway API v1.0

1 participant