Skip to content

Commit 8ecfd4d

Browse files
committed
Add support for HTTPOption
1 parent 217f929 commit 8ecfd4d

16 files changed

+576
-73
lines changed

config/config-gateway.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ data:
5050
- class: istio
5151
gateway: istio-system/knative-gateway
5252
service: istio-system/istio-ingressgateway
53+
http-listener-name: http
5354
supported-features:
5455
- HTTPRouteRequestTimeout
5556
@@ -58,5 +59,6 @@ data:
5859
- class: istio
5960
gateway: istio-system/knative-local-gateway
6061
service: istio-system/knative-local-gateway
62+
http-listener-name: http
6163
supported-features:
6264
- HTTPRouteRequestTimeout

docs/test-version.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ The following Gateway API version and Ingress were tested as part of the release
1515

1616
| Ingress | Tested version | Unavailable features |
1717
| ------- | ----------------------- | ------------------------------ |
18-
| Istio | v1.22.1 | retry,httpoption |
19-
| Contour | v1.29.1 | httpoption |
18+
| Istio | v1.22.1 | retry |
19+
| Contour | v1.29.1 | |

hack/test-env.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
export GATEWAY_API_VERSION="v1.1.0"
1818
export ISTIO_VERSION="1.22.1"
19-
export ISTIO_UNSUPPORTED_E2E_TESTS="retry,httpoption"
19+
export ISTIO_UNSUPPORTED_E2E_TESTS="retry"
2020
export CONTOUR_VERSION="v1.29.1"
21-
export CONTOUR_UNSUPPORTED_E2E_TESTS="httpoption"
21+
export CONTOUR_UNSUPPORTED_E2E_TESTS=""
2222

2323
export ENVOY_GATEWAY_VERSION="latest"
24-
export ENVOY_GATEWAY_UNSUPPORTED_E2E_TESTS="httpoption,host-rewrite"
24+
export ENVOY_GATEWAY_UNSUPPORTED_E2E_TESTS="host-rewrite"

pkg/reconciler/ingress/config/gateway.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func defaultExternalGateways() []Gateway {
4747
Name: "istio-ingressgateway",
4848
Namespace: "istio-system",
4949
},
50+
HTTPListenerName: "http",
5051
SupportedFeatures: sets.New(
5152
features.SupportHTTPRouteRequestTimeout,
5253
),
@@ -64,6 +65,7 @@ func defaultLocalGateways() []Gateway {
6465
Name: "knative-local-gateway",
6566
Namespace: "istio-system",
6667
},
68+
HTTPListenerName: "http",
6769
SupportedFeatures: sets.New(
6870
features.SupportHTTPRouteRequestTimeout,
6971
),
@@ -90,6 +92,7 @@ type Gateway struct {
9092
types.NamespacedName
9193

9294
Class string
95+
HTTPListenerName string
9396
Service *types.NamespacedName
9497
SupportedFeatures sets.Set[features.SupportedFeature]
9598
}
@@ -138,6 +141,7 @@ type gatewayEntry struct {
138141
Gateway string `json:"gateway"`
139142
Service *string `json:"service"`
140143
Class string `json:"class"`
144+
HTTPListenerName string `json:"http-listener-name"`
141145
SupportedFeatures []features.SupportedFeature `json:"supported-features"`
142146
}
143147

@@ -152,6 +156,7 @@ func parseGatewayConfig(data string) ([]Gateway, error) {
152156
for i, entry := range entries {
153157
gw := Gateway{
154158
Class: entry.Class,
159+
HTTPListenerName: entry.HTTPListenerName,
155160
SupportedFeatures: sets.New(entry.SupportedFeatures...),
156161
}
157162

@@ -174,6 +179,9 @@ func parseGatewayConfig(data string) ([]Gateway, error) {
174179
if len(strings.TrimSpace(gw.Class)) == 0 {
175180
return nil, fmt.Errorf(`entry [%d] field "class" is required`, i)
176181
}
182+
if len(strings.TrimSpace(gw.HTTPListenerName)) == 0 {
183+
return nil, fmt.Errorf(`entry [%d] field "http-listener-name" is required`, i)
184+
}
177185

178186
gws = append(gws, gw)
179187
}

pkg/reconciler/ingress/config/gateway_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ func TestFromConfigMapErrors(t *testing.T) {
5858
data: map[string]string{
5959
"external-gateways": `[{
6060
"class":"boo",
61+
"http-listener-name":"http",
6162
"gateway": "ns/n"
6263
},{
6364
"class":"boo",
65+
"http-listener-name":"http",
6466
"gateway": "ns/n"
6567
}]`,
6668
},
@@ -70,9 +72,11 @@ func TestFromConfigMapErrors(t *testing.T) {
7072
data: map[string]string{
7173
"local-gateways": `[{
7274
"class":"boo",
75+
"http-listener-name":"http",
7376
"gateway": "ns/n"
7477
},{
7578
"class":"boo",
79+
"http-listener-name":"http",
7680
"gateway": "ns/n"
7781
}]`,
7882
},
@@ -119,6 +123,12 @@ func TestFromConfigMapErrors(t *testing.T) {
119123
"local-gateways": `[{"class": "class", "gateway": "ns/n", "service":"name"}]`,
120124
},
121125
want: `unable to parse "local-gateways"`,
126+
}, {
127+
name: "missing gateway http-listener-name",
128+
data: map[string]string{
129+
"local-gateways": `[{"class":"class", "gateway": "namespace/name"}]`,
130+
},
131+
want: `unable to parse "local-gateways": entry [0] field "http-listener-name" is required`,
122132
}}
123133

124134
for _, tc := range cases {
@@ -141,9 +151,11 @@ func TestGatewayNoService(t *testing.T) {
141151
Data: map[string]string{
142152
"external-gateways": `
143153
- class: istio
154+
http-listener-name: http
144155
gateway: istio-system/knative-gateway`,
145156
"local-gateways": `
146157
- class: istio
158+
http-listener-name: http
147159
gateway: istio-system/knative-local-gateway`,
148160
},
149161
})

pkg/reconciler/ingress/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import (
3333
_ "knative.dev/pkg/client/injection/kube/informers/core/v1/endpoints/fake"
3434
_ "knative.dev/pkg/client/injection/kube/informers/core/v1/pod/fake"
3535

36-
. "knative.dev/pkg/reconciler/testing"
36+
ktesting "knative.dev/pkg/reconciler/testing"
3737
)
3838

3939
func TestNew(t *testing.T) {
40-
ctx, _ := SetupFakeContext(t)
40+
ctx, _ := ktesting.SetupFakeContext(t)
4141

4242
c := NewController(ctx, configmap.NewStaticWatcher(&corev1.ConfigMap{
4343
ObjectMeta: metav1.ObjectMeta{

pkg/reconciler/ingress/ingress.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,22 @@ func (c *Reconciler) reconcileIngress(ctx context.Context, ing *v1alpha1.Ingress
107107
for _, rule := range ing.Spec.Rules {
108108
rule := rule
109109

110-
httproute, probeTargets, err := c.reconcileHTTPRoute(ctx, ingressHash, ing, &rule)
110+
workloadRoute, probeTargets, err := c.reconcileWorkloadRoute(ctx, ingressHash, ing, &rule)
111111
if err != nil {
112112
return err
113113
}
114114

115-
if isHTTPRouteReady(httproute) {
115+
// For now, we only generate the redirected HTTPRoute for external visibility,
116+
// because currently we do not (yet) support HTTPs for cluster-local domains in net-gateway-api.
117+
var redirectRoute *gatewayapi.HTTPRoute
118+
if ing.Spec.HTTPOption == v1alpha1.HTTPOptionRedirected && rule.Visibility == v1alpha1.IngressVisibilityExternalIP {
119+
redirectRoute, err = c.reconcileRedirectHTTPRoute(ctx, ing, &rule)
120+
if err != nil {
121+
return err
122+
}
123+
}
124+
125+
if isHTTPRouteReady(workloadRoute) && (redirectRoute == nil || isHTTPRouteReady(redirectRoute)) {
116126
ing.Status.MarkNetworkConfigured()
117127

118128
state, err := c.statusManager.DoProbes(ctx, probeTargets)

0 commit comments

Comments
 (0)