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

Support Gateway Selection using Ingress Labels #1250

Merged
merged 5 commits into from
Mar 27, 2024

Conversation

pastequo
Copy link
Contributor

@pastequo pastequo commented Jan 26, 2024

Changes

This PR was built on top of #1249

This is why there are a lot of changes (it includes 2 PRs in one)

  • Introduce LabelSelector on istio config
  • Filter gateway to use based on ingress labels & configuration label selector

/kind enhancement

Fixes #1248

Release Note

Services can be exposed by a specific istio gateway. Administrators, by using the new istio config format, are able to associate a label selector to their istio gateway. More information [here](https://docs.google.com/document/d/12X1-9nhjAhpf-Wlt3RbdoMbvx31zFBva/edit#heading=h.gjdgxs)

Docs


Copy link

knative-prow bot commented Jan 26, 2024

@pastequo: The label(s) kind/<kind> cannot be applied, because the repository doesn't have them.

In response to this:

Changes

This PR was built on top of #1249

  • Introduce LabelSelector on istio config
  • Filter gateway to use based on ingress labels & configuration label selector

/kind

Fixes #1248

Release Note


Docs


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow knative-prow bot requested review from skonto and upodroid January 26, 2024 14:29
@knative-prow knative-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 26, 2024
Copy link

knative-prow bot commented Jan 26, 2024

Hi @pastequo. Thanks for your PR.

I'm waiting for a knative-extensions member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: Patch coverage is 83.64780% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 80.28%. Comparing base (e73d356) to head (1f02be8).
Report is 1 commits behind head on main.

Files Patch % Lines
pkg/reconciler/ingress/resources/gateway.go 76.74% 13 Missing and 7 partials ⚠️
pkg/reconciler/ingress/ingress.go 90.00% 2 Missing and 1 partial ⚠️
pkg/reconciler/ingress/lister.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1250      +/-   ##
==========================================
- Coverage   80.51%   80.28%   -0.24%     
==========================================
  Files          26       26              
  Lines        2022     2115      +93     
==========================================
+ Hits         1628     1698      +70     
- Misses        301      316      +15     
- Partials       93      101       +8     

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

@pastequo pastequo force-pushed the feat/gateway-filtering branch from 139dd4f to 1363f09 Compare January 29, 2024 16:25
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 29, 2024
@pastequo pastequo force-pushed the feat/gateway-filtering branch from 1363f09 to 23a0d7e Compare January 29, 2024 16:53
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 29, 2024
@pastequo pastequo force-pushed the feat/gateway-filtering branch from 23a0d7e to 1682c45 Compare January 29, 2024 17:22
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2024
@pastequo pastequo force-pushed the feat/gateway-filtering branch from 8548431 to 060b8f9 Compare January 30, 2024 17:22
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2024
@pastequo
Copy link
Contributor Author

Contrary to what was documented, I felt like it was wrong to implement here the check about the number of gateway (for example a maximum of one external gateway should be selected thru labels)

Even if it's not officially supported, a great part of the code acts as multiple gateway is possible. In particular, a lot of tests are using a configuration with multiple gateways.

If the change is confirmed, I think it should be done on a separated PR

@dprotaso
Copy link
Contributor

dprotaso commented Feb 6, 2024

You'll need to rebase since the prior PR merged.

I felt like it was wrong to implement here the check about the number of gateway (for example a maximum of one external gateway should be selected thru labels)

I'll bring it up at the WG group meeting tomorrow to see what others think.

My thoughts are given that we don't probe all gateways you could say allowing that behaviour is broken. If we have a plan to address the broken behaviour then we can drop the check.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 6, 2024
@dprotaso
Copy link
Contributor

dprotaso commented Feb 6, 2024

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 6, 2024
@dprotaso
Copy link
Contributor

dprotaso commented Feb 7, 2024

Following up from the WG discussion - we'll want to add a check to ensure only a single gateway is selected (cause that's all we support). It's fine that this is done after this PR lands in a follow up change

@pastequo pastequo force-pushed the feat/gateway-filtering branch 2 times, most recently from 0682f4b to 4985d97 Compare February 8, 2024 09:45
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 8, 2024
@pastequo pastequo force-pushed the feat/gateway-filtering branch 2 times, most recently from c237ceb to af986a0 Compare February 8, 2024 10:12
@pastequo
Copy link
Contributor Author

pastequo commented Feb 8, 2024

/retest

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2024
@pastequo pastequo force-pushed the feat/gateway-filtering branch from af986a0 to 27c845a Compare February 16, 2024 11:53
Name: parts[0],
Namespace: parts[1],
// GetIngressGatewaySvcNameNamespaces gets the Istio ingress namespaces from ConfigMap for gateways that should expose the service.
func GetIngressGatewaySvcNameNamespaces(ctx context.Context, obj kmeta.Accessor) ([]metav1.ObjectMeta, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that wherever we have a kmeta.Accessor we could replace it with ing *v1alpha1.Ingress, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I used to have ing *v1alpha1.Ingress & @dprotaso made me change for this. Which is imho better to depends on a small interface rather than an implementation

See #1250 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

It depends generalizing for one case it is still weird but maybe a good fir for the GetLabels method.

}
}

func replaceTabs(s string) string {
Copy link
Contributor

@skonto skonto Mar 12, 2024

Choose a reason for hiding this comment

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

We could have as an alternative, something like:

func toYamlNewFormatGateways(data []Gateway) string {
	bytes, _ := yaml.Marshal(data)
	return string(bytes)
}

"external-gateways": toYamlNewFormatGateways([]Gateway{
  {
    Namespace:  "unused",
    Name:       "unused",
    ServiceURL: "default.default.svc.cluster.local",
  },
  {
    Namespace:  "namespace",
    Name:       "gateway",
    ServiceURL: "istio-gateway.istio-system.svc.cluster.local",
    LabelSelector: &metav1.LabelSelector{
      MatchExpressions: []metav1.LabelSelectorRequirement{
        {
          Key:      "key",
          Operator: metav1.LabelSelectorOpIn,
          Values:   []string{"value"},
        },
      },
    },
  }},
),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I rather have a string that reflects exactly what a user would have written, rather than generate it

Copy link
Contributor

Choose a reason for hiding this comment

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

For the scenarios you want to check just the user syntax yes, for the rest where you want to run test cases based on valid content it is safer. Anyway no strong preference.

@pastequo pastequo force-pushed the feat/gateway-filtering branch from f06b35a to 72c817c Compare March 12, 2024 16:15
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 12, 2024
@pastequo
Copy link
Contributor Author

I think we should document this feature. Is this something we plan to do?

Do you mean aside from the google doc ? https://docs.google.com/document/d/12X1-9nhjAhpf-Wlt3RbdoMbvx31zFBva/edit#heading=h.gjdgxs

Something here https://github.com/knative/docs ? Or somewhere else ?

@skonto
Copy link
Contributor

skonto commented Mar 13, 2024

Something here https://github.com/knative/docs ?

yes

@pastequo
Copy link
Contributor Author

Issue created: knative/docs#5905

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 14, 2024
@dprotaso
Copy link
Contributor

/approve

Leaving lgtm for stavros

Copy link

knative-prow bot commented Mar 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, pastequo

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 Mar 21, 2024
@skonto
Copy link
Contributor

skonto commented Mar 27, 2024

@pastequo could you rebase pls so we can stamp it?

@pastequo pastequo force-pushed the feat/gateway-filtering branch from 0d92608 to 1f02be8 Compare March 27, 2024 12:59
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 27, 2024
@skonto
Copy link
Contributor

skonto commented Mar 27, 2024

/lgtm
/hold for tests

@knative-prow knative-prow bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Mar 27, 2024
@skonto
Copy link
Contributor

skonto commented Mar 27, 2024

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 27, 2024
@knative-prow knative-prow bot merged commit 52c9a7a into knative-extensions:main Mar 27, 2024
40 checks passed
@dprotaso
Copy link
Contributor

🎉 thanks @pastequo for your help on landing this

@dprotaso dprotaso changed the title Feat/gateway filtering Support Gateway Selection using Ingress Labels Mar 27, 2024
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filtering on external istio gateway
5 participants