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

Generate per-Ingress Gateway instead of reconciling the global Ingress Gateway when auto TLS is enabled #170

Merged

Conversation

ZhiminXiang
Copy link

@ZhiminXiang ZhiminXiang commented Jul 5, 2020

Currently when auto TLS is enabled, the controller updates the global Gateway to configure TLS. This is not a good pattern because:

  1. The global Gateway object could become very big, and exceeds the object size limit.
  2. Currently multiple threads try to update the single Gateway, which could be easily conflicted.

This PR moves the TLS servers within a global Gateway to an independent Gateway, and makes VirtualService also attach to it.

This PR is backward compatible, and should not affect the ongoing traffic because from Istio's perspective, the Gateway related configurations are kept as the same.

This PR will not affect any behavior when auto TLS is disabled.

Fix knative/serving#4312

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 5, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 5, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 5, 2020
@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 5, 2020
@zhanggbj
Copy link

zhanggbj commented Jul 6, 2020

Hi @ZhiminXiang ,
I'm wondering if it is possible to add a new feature flag for splitting gateway instead of using autoTLS flag. As in our user scenario,

  • We have autoTLS disabled as we're generating Certificate with our own cert service.
  • However, we do want to have splitting gateway as above as so far we may have 500~1000 host https entries in the single Gateway.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 8, 2020
@ZhiminXiang
Copy link
Author

@zhanggbj I am not sure very sure about your use case.
The Gateway split will be triggered if 1) IngressTLS is set or 2) auto TLS is enabled. So your use case does not fall into either of those 2?

@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 29, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ZhiminXiang

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

@ZhiminXiang
Copy link
Author

/cc @tcnghia @nak3 @JRBANCEL

@ZhiminXiang ZhiminXiang changed the title [WIP] Generate per-Ingress Gateway instead of reconciling the global Ingress Gateway when auto TLS is enabled Generate per-Ingress Gateway instead of reconciling the global Ingress Gateway when auto TLS is enabled Jul 29, 2020
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 29, 2020
@zhanggbj
Copy link

zhanggbj commented Jul 29, 2020

@ZhiminXiang
In our case, autoTLS=false, as we are using our own Cert service (I guess this also may be true for others).
and ingressTLS is also empty, if I understand it correctly, you mean this one? https://github.com/knative-sandbox/net-istio/blob/master/vendor/knative.dev/networking/pkg/apis/networking/v1alpha1/ingress_types.go#L47

Here is what we have in knative ingress

spec:
  rules:
  - hosts:
    - blue.ceperfhttp-1.svc.cluster.local
    http:
      paths:
      - splits:
        - appendHeaders:
            Knative-Serving-Namespace: ceperfhttp-1
            Knative-Serving-Revision: blue-tnyrz-1
          percent: 100
          serviceName: blue-tnyrz-1
          serviceNamespace: ceperfhttp-1
          servicePort: 80
        timeout: 10m0s
    visibility: ClusterLocal
  - hosts:
    - blue.ceperfhttp-1.dev-serving.codeengine.dev.appdomain.cloud
    http:
      paths:
      - splits:
        - appendHeaders:
            Knative-Serving-Namespace: ceperfhttp-1
            Knative-Serving-Revision: blue-tnyrz-1
          percent: 100
          serviceName: blue-tnyrz-1
          serviceNamespace: ceperfhttp-1
          servicePort: 80
        timeout: 10m0s
    visibility: ExternalIP
  visibility: ExternalIP

but in facts, we have TLS configs in gateway

  - hosts:
    - '*.ceperfhttp-1.dev-serving.knative.dev.appdomain.cloud'
    port:
      name: https-ceperfhttp-1
      number: 443
      protocol: HTTPS
    tls:
      credentialName: ceperfhttp-1
      mode: SIMPLE
      subjectAltNames: []

func MakeIngressGateways(ctx context.Context, ing *v1alpha1.Ingress, originSecrets map[string]*corev1.Secret, svcLister corev1listers.ServiceLister) ([]*v1beta1.Gateway, error) {
// MakeIngressTLSGateways creates Gateways for a given Ingress.
func MakeIngressTLSGateways(ctx context.Context, ing *v1alpha1.Ingress, ingressTLS []v1alpha1.IngressTLS, originSecrets map[string]*corev1.Secret, svcLister corev1listers.ServiceLister) ([]*v1beta1.Gateway, error) {
// No need to create Gateway if there is no related ingress TLS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be more future proof to create a Gateway per ksvc, no matter if TLS is here or not.
This way, it is there, already scoped to the specific hosts. Because otherwise I worried we go from a global gateway to a custom one just because TLS was enabled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider the Gateway split as two parts: TLS Gateway split and non-TLS (or HTTP) Gateway Split.

It seems no doubt that we need TLS Gateway split as we don't want to keep reconciling the global Gateway.

For non-TLS Gateway split, I think we need more considerations. Currently we do not provide a way to configure the non-TLS behavior through Kingerss. So all Kingresses have the same HTTP behavior by default (unless users directly change the Gateway). From this perspective, I am a little concerned that splitting non-TLS Gateway may cause performance regression for the default behavior (as Istio pilot now needs merging Gateway).

wildcardGatewayNames = resources.GetQualifiedGatewayNames(desiredWildcardGateways)

// VirtualService will be attached to both global Gateways and the Knative generated Gateways.
// We still want to attach to the global Gateways to respect any global Gateway configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work though?
By global Gateway, I am assuming you mean a * Gateway?
In this case, the more specific Gateway will be picked and other ignored, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more specific Gateway (or Knative generated Gateway) only has the TLS configuration.
In this PR, I plan to just simply move the TLS configuration from the global Gateway to the more specific Gateway. So for the TLS part, there is no conflict when attaching VirtualService to both global and the more specific Gateway.

And by attaching VirtualService to the global Gateway, I want to retain the non-TLS behavior for the backward compatibility reason.

@JRBANCEL
Copy link
Contributor

JRBANCEL commented Aug 6, 2020

/lgtm

@knative-prow-robot knative-prow-robot added lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 6, 2020
@knative-prow-robot knative-prow-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 7, 2020
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-sandbox-net-istio-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/ingress/ingress.go 80.5% 81.8% 1.3
pkg/reconciler/ingress/resources/gateway.go 86.6% 85.7% -0.9

@JRBANCEL
Copy link
Contributor

JRBANCEL commented Aug 7, 2020

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2020
@knative-prow-robot knative-prow-robot merged commit 4369c9c into knative-extensions:master Aug 7, 2020
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split the global shared Gateway when Gateway reconcilation is turned on
6 participants