Skip to content

Commit

Permalink
Limit redirect route generation to external traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
ReToCode committed Jan 19, 2023
1 parent e5dac81 commit 9a9faf8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/config-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ data:
class: istio
gateway: istio-system/knative-local-gateway
service: istio-system/knative-local-gateway
httpListenerName: http2
httpListenerName: default
2 changes: 1 addition & 1 deletion pkg/reconciler/ingress/config/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
defaultGatewayClass = "istio"

// defaultClusterLocalHTTPListener is the name of the listener for HTTP traffic
defaultClusterLocalHTTPListener = "http2"
defaultClusterLocalHTTPListener = "default"

// defaultExternalIPHTTPListener
defaultExternalIPHTTPListener = "default"
Expand Down
4 changes: 3 additions & 1 deletion pkg/reconciler/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ func (c *Reconciler) reconcileIngress(ctx context.Context, ing *v1alpha1.Ingress
return err
}

// For now, we only generate the redirected HTTPRoute for external visibility,
// because there's no way to provide TLS for internal listeners.
var redirectHTTPRoute *gatewayapi.HTTPRoute
if ing.Spec.HTTPOption == v1alpha1.HTTPOptionRedirected {
if ing.Spec.HTTPOption == v1alpha1.HTTPOptionRedirected && rule.Visibility == v1alpha1.IngressVisibilityExternalIP {
redirectHTTPRoute, err = c.reconcileRedirectHTTPRoute(ctx, ing, &rule)
if err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions pkg/reconciler/ingress/reconcile_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ func (c *Reconciler) reconcileWorkloadRoute(
Name: gatewayapi.ObjectName(gatewayConfig.Gateway.Name),
}

// if http > https redirect is enabled, this route must only be bound to the TLS listener on the gateway
if ing.Spec.HTTPOption == netv1alpha1.HTTPOptionRedirected {
// If http > https redirect is enabled, this route must only be bound to the TLS listener on the gateway.
// For now, we only generate the TLS Listener on the external traffic gateway
// because there's no way to provide TLS for internal listeners.
if ing.Spec.HTTPOption == netv1alpha1.HTTPOptionRedirected && rule.Visibility == netv1alpha1.IngressVisibilityExternalIP {
sectionName := gatewayapi.SectionName(listenerPrefix + ing.GetUID())
gatewayRef.SectionName = &sectionName
}
Expand Down

0 comments on commit 9a9faf8

Please sign in to comment.