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

Apply namespace scoping to Gateway servers in samples #34035

Closed
wants to merge 2 commits into from

Conversation

kailun-qin
Copy link
Member

@kailun-qin kailun-qin commented Jul 14, 2021

Gateways allow namespace bound virtual service selection (e.g.,
foo/foo.example.com). This is a good security best practice.

This patch spreads this usage to all samples to restrict the set of
virtual services that can bind to a gateway server.

Fixes #33977

Signed-off-by: Kailun Qin kailun.qin@intel.com

[ ] Configuration Infrastructure
[x] Docs
[ ] Installation
[x] Networking
[ ] Performance and Scalability
[ ] Policies and Telemetry
[ ] Security
[ ] Test and Release
[ ] User Experience
[ ] Developer Infrastructure

Pull Request Attributes

Please check any characteristics that apply to this pull request.

[x] Does not have any user-facing changes. This may include CLI changes, API changes, behavior changes, performance improvements, etc.

@kailun-qin kailun-qin requested review from a team as code owners July 14, 2021 09:46
@istio-policy-bot istio-policy-bot added area/networking release-notes-none Indicates a PR that does not require release notes. labels Jul 14, 2021
@google-cla google-cla bot added the cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. label Jul 14, 2021
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 14, 2021
Copy link
Member

@nrjpoddar nrjpoddar left a comment

Choose a reason for hiding this comment

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

Love these changes! Thanks for doing this @kailun-qin.

We would need to change the istio.io examples/tasks too or else the docs and bundled sample resources will be out of sync?

@craigbox
Copy link
Contributor

We should also give though to whether it makes it more complicated to understand by looking at the samples, as these are some of the things we use to teach Istio to people.

@craigbox craigbox closed this Jul 14, 2021
@craigbox craigbox reopened this Jul 14, 2021
@@ -11,7 +11,7 @@ spec:
name: http
protocol: HTTP
hosts:
- "*"
- "default/*"
Copy link
Member

Choose a reason for hiding this comment

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

Problem with this is the YAML itself is not namespace bound. So they can apply anywhere, and then this won't work.

Maybe we should have allowed ./* in the code...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, an alternative is to explicitly specify the namespaces for the YAMLs so that they can be bound together. The namespace to bind should align w/ the sample READMEs.

In this way, when kubectl apply w/ no explicit ns set, the resources will by default be applied to the exact ns specified in the Pod spec. And when kubectl apply w/ explicit -n <ns_name>, there'll be an error returned to users when they try to apply it elsewhere (message like the namespace from the provided object "istio-system" does not match the namespace "default". You must pass '--namespace=istio-system' to perform this operation.), which is guaranteed by kubectl.

Does this approach make sense to you @howardjohn? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Some of these resources (e.g., bookinfo ones) are intended to be used in whatever namespace the user wants. Even the Istio tasks use different namepaces (e.g., some use default, others use ns bookinfo). Outside blogs and other docs also rely on the namespace flexibility, so this would be unacceptable breaking change IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comments!

If it's the case, I think maybe we should have allowed * in the code. We should only apply ns scoping to the samples where the YAMLs have already bound w/ specific ns, e.g. samples/bookinfo/networking/certmanager-gateway.yaml, samples/multicluster etc.

WDYT @frankbu @howardjohn?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should only apply ns scoping to the samples where the YAMLs have already bound w/ specific ns

That makes sense but I don't think there are very many of those. The samples/multicluster east-west gateways are not always in istio-system. For example, see the external control plane doc: https://preliminary.istio.io/latest/docs/setup/install/external-controlplane/#setup-east-west-gateways

Copy link
Contributor

@frankbu frankbu Jul 15, 2021

Choose a reason for hiding this comment

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

btw, another recommended best practice is to use fully-qualified hosts in VirtualServices (e.g., reviews.default.svc.cluster.local insead of just reviews), but we haven't done that in the samples either, for the same reason.

Maybe we need to add more best practices to the docs and put some tips in the tasks/examples that point to them.

@kailun-qin
Copy link
Member Author

Love these changes! Thanks for doing this @kailun-qin.

We would need to change the istio.io examples/tasks too or else the docs and bundled sample resources will be out of sync?

Thanks! Yes, we do need to update the related if this change itself makes sense.

@kailun-qin
Copy link
Member Author

We should also give though to whether it makes it more complicated to understand by looking at the samples, as these are some of the things we use to teach Istio to people.

Agree. IMO this looks fine for readability. Additional doc/comments can be updated if not clear enough.

Gateways allow namespace bound virtual service selection (e.g.,
foo/foo.example.com). This is a good security best practice.

This patch spreads this usage to all samples to restrict the set of
virtual services that can bind to a gateway server.

Fixes istio#33977

Signed-off-by: Kailun Qin <kailun.qin@intel.com>
@kailun-qin
Copy link
Member Author

/retest

Signed-off-by: Kailun Qin <kailun.qin@intel.com>
@istio-policy-bot istio-policy-bot added the lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while label Aug 15, 2021
@istio-policy-bot
Copy link

🚧 This issue or pull request has been closed due to not having had activity from an Istio team member since 2021-07-15. If you feel this issue or pull request deserves attention, please reopen the issue. Please see this wiki page for more information. Thank you for your contributions.

Created by the issue and PR lifecycle manager.

@istio-policy-bot istio-policy-bot added the lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. label Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/networking cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while release-notes-none Indicates a PR that does not require release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve documentation on namespace scoping of routes
7 participants