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

Allow HTTP->HTTPS redirection on Istio Gateway #1912

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

houshengbo
Copy link
Contributor

@houshengbo houshengbo commented Oct 14, 2024

Extends #1482.

One of the ServerTLSSettings on Istio Gatway is httpsRedirect that, according to docs, redirects HTTP traffic to HTTPS. Usually this is a desired behaviour for production setup, the only alternative would be to not create HTTP listener at all.

PR leverages combination of nullable property and oneOf with required fields - this works fine currently as there is 2 distinct options (mode: <>, which requires credentialName to be set, or httpsRedirect, which is mutually exclusive with every other option), but it might become cumbersome if more options of different combinations are added.

Tested with the following specs:

spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*.example.com'
    port:
      name: http
      number: 80
      protocol: HTTP
    tls:
      httpsRedirect: true
  - hosts:
    - '*.example.com'
    port:
      name: https-production
      number: 443
      protocol: https
    tls:
      credentialName: example-tls
      mode: SIMPLE

and

spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*.example.com'
    port:
      name: http
      number: 80
      protocol: HTTP
  - hosts:
    - '*.example.com'
    port:
      name: https-production
      number: 443
      protocol: https
    tls:
      credentialName: example-tls
      mode: SIMPLE

Both produce correct Gateways.

Kubernetes 1.30 (EKS), Knative Operator 1.15.4, Knative Serving 1.15.0, Istio 1.23.0.

Proposed Changes

  • Allows HTTP listener on Istio Gateway to be configured with automatic HTTP->HTTPS redirection.

Release Note

feature: Istio Gateway can be configured with automatic HTTP->HTTPS redirection

@knative-prow knative-prow bot requested review from aliok and matzew October 14, 2024 16:14
@knative-prow knative-prow bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 14, 2024
Copy link

knative-prow bot commented Oct 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: houshengbo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 14, 2024
Copy link

codecov bot commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.49%. Comparing base (a1fef51) to head (94853f6).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1912   +/-   ##
=======================================
  Coverage   66.49%   66.49%           
=======================================
  Files          54       54           
  Lines        2107     2107           
=======================================
  Hits         1401     1401           
  Misses        589      589           
  Partials      117      117           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@houshengbo houshengbo added the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2024
@houshengbo
Copy link
Contributor Author

@penguinush There is something wrong with the CI. I have to reopen a new PR to make them pass.

@knative-prow knative-prow bot merged commit fdf1afb into knative:main Oct 14, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants