Skip to content

Commit 5930d13

Browse files
committed
Add Gateway API provider configuration and validation
Signed-off-by: Mateusz Paluszkiewicz <theaifam5@gmail.com>
1 parent f7e39cf commit 5930d13

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

cilium.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
locals {
2+
cilium_gateway_enabled = var.cilium_enabled && var.gateway_api_provider == "cilium"
3+
24
# Cilium IPSec Configuration
35
cilium_ipsec_enabled = var.cilium_encryption_enabled && var.cilium_encryption_type == "ipsec"
46

@@ -31,7 +33,7 @@ locals {
3133
} : null
3234

3335
# Cilium integration with Gateway API
34-
cilium_gateway_api_manifest = var.gateway_api_enabled ? {
36+
cilium_gateway_api_manifest = local.cilium_gateway_enabled ? {
3537
apiVersion = "gateway.networking.k8s.io/v1"
3638
kind = "GatewayClass"
3739
metadata = {
@@ -111,7 +113,7 @@ data "helm_template" "cilium" {
111113
acceleration = "native"
112114
}
113115
gatewayAPI = {
114-
enabled = var.gateway_api_enabled
116+
enabled = local.cilium_gateway_enabled
115117
enableProxyProtocol = true
116118
externalTrafficPolicy = var.ingress_service_external_traffic_policy
117119
}

variables.tf

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,14 +1669,50 @@ variable "gateway_api_enabled" {
16691669
description = "Enables the Gateway API Custom Resource Definitions (CRDs) deployment."
16701670
}
16711671

1672+
variable "gateway_api_provider" {
1673+
type = string
1674+
default = "cilium"
1675+
description = "Specifies the Gateway API provider. Options are 'cilium' (Cilium Controller), or 'ingate' (InGate Ingress & Gateway API Controller)."
1676+
1677+
validation {
1678+
condition = contains(["cilium", "ingate"], var.gateway_api_provider)
1679+
error_message = "Invalid Gateway API provider. Allowed values are 'cilium', or 'ingate'."
1680+
}
1681+
1682+
validation {
1683+
condition = var.gateway_api_provider != "cilium" || var.cilium_enabled
1684+
error_message = "Gateway API provider cannot be set to 'cilium' unless Cilium is also enabled."
1685+
}
1686+
1687+
validation {
1688+
condition = var.gateway_api_provider != "ingate"
1689+
error_message = "Gateway API provider 'ingate' is not yet supported."
1690+
}
1691+
}
1692+
16721693
variable "gateway_api_version" {
16731694
type = string
16741695
default = "v1.3.0" # https://github.com/kubernetes-sigs/gateway-api
16751696
description = "Specifies the version of the Gateway API Custom Resource Definitions (CRDs) to deploy."
16761697

1698+
# Cilium provider constraints
1699+
validation {
1700+
condition = (
1701+
var.gateway_api_provider != "cilium" ||
1702+
(var.gateway_api_provider == "cilium" &&
1703+
var.cilium_helm_version == "v1.18.2" &&
1704+
var.gateway_api_version == "v1.3.0")
1705+
)
1706+
error_message = "When gateway_api_provider is 'cilium', cilium_helm_version must be 'v1.18.2' and gateway_api_version must be 'v1.3.0'."
1707+
}
1708+
1709+
# InGate provider constraints (will also fail due to provider-level validation)
16771710
validation {
1678-
condition = var.ingress_controller_type != "cilium" || (var.cilium_helm_version == "v1.18.2" && var.gateway_api_version == "v1.3.0")
1679-
error_message = "When ingress_controller_type is 'cilium', cilium_helm_version must be 'v1.18.2' and gateway_api_version must be 'v1.3.0'."
1711+
condition = (
1712+
var.gateway_api_provider != "ingate" ||
1713+
(var.gateway_api_provider == "ingate" && var.gateway_api_version == "v1.2.0")
1714+
)
1715+
error_message = "When gateway_api_provider is 'ingate', gateway_api_version must be 'v1.2.0'."
16801716
}
16811717
}
16821718

0 commit comments

Comments
 (0)