Skip to content

Conversation

ramaraochavali
Copy link
Contributor

Envoy now supports configuring cidrs that should be treated as internal addresses https://github.com/envoyproxy/envoy/blob/main/api/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#L209.

This affects how Envoy treats incoming connections as internal or external. In some of envs, RFC 1918 is not followed for internal addresses.

This allows a mesh to configure internal addresses cidrs

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@istio-policy-bot
Copy link

😊 Welcome @ramaraochavali! This is either your first contribution to the Istio api repo, or it's been
awhile since you've been here.

You can learn more about the Istio working groups, code of conduct, and contributing guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@istio-testing istio-testing added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 5, 2022
@ramaraochavali ramaraochavali added release-notes-none Indicates a PR that does not require release notes. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 5, 2022
Copy link
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

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

I was also looking at something like this - not sure what your use case is, but I am trying to simplify the configuration of 'egress gateway' by redirecting all non-internal addresses to the gateway. Still working on a RFC..

What I was thinking was to actually extend the existing 'networks'. In other words, a user may have a multi-network mesh, with each network having a set of 'internal cidr ranges' - and we already have a config to define that via MeshNetworks.fromCidr.

The equivalent of what you propose is using
default:

  • fromCidr: ....

@@ -1088,8 +1088,12 @@ message MeshConfig {
// Configuration of mTLS for traffic between workloads within the mesh.
TLSConfig mesh_mTLS = 63;

// List of CIDR ranges that are treated as internal. If unset, then RFC1918 / RFC4193
// IP addresses will be considered internal.
repeated string internal_addresses = 64;
Copy link
Contributor

Choose a reason for hiding this comment

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

But what happens if it is set ? Are those extras ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this is set, the cidr range specified here would be considered as internal address instead of default one

Copy link
Member

@zirain zirain Apr 7, 2022

Choose a reason for hiding this comment

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

do we need set all clusters' pod cidrs(in a multi clusters mesh) here for best practice?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not for 'best practice' - it won't work otherwise... But I think if you add the ranges above it'll cover all the mesh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need set all clusters' pod cidrs(in a multi clusters mesh) here for best practice
No.

Yes. If we add the ranges above, it covers the entire mesh

@costinm
Copy link
Contributor

costinm commented Apr 6, 2022 via email

@hzxuzhonghu
Copy link
Member

Can you elaborate how internal address is treated differently

@ramaraochavali
Copy link
Contributor Author

ramaraochavali commented Apr 6, 2022

@hzxuzhonghu Envoy sets "x-envoy-internal" header and services can use it to decide whether the call is from internal mesh/public. That is a common usecase.

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@istio-testing istio-testing added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 6, 2022
@ramaraochavali
Copy link
Contributor Author

@costinm That makes sense. I updated the comments.

@hzxuzhonghu
Copy link
Member

@hzxuzhonghu Envoy sets "x-envoy-internal" header and services can use it to decide whether the call is from internal mesh/public. That is a common usecase.

Why could not infer this from other headers?

@ramaraochavali
Copy link
Contributor Author

Why could not infer this from other headers?

Which header?

@hzxuzhonghu
Copy link
Member

x-envoy-xxx

@ramaraochavali
Copy link
Contributor Author

x-envoy-xxx

which header? x-envoy-internal is the one which tells whether the address is internal or external and it is derived from xff (which is again based on this value)

@hzxuzhonghu
Copy link
Member

Oh, I misunderstood a little about the background. Since for istio internal mesh sidecar-sidecar communication, no xff is appended. only external-call --> gateway--> server, xff is generated. By looking at this header, could know if it is external

@ramaraochavali
Copy link
Contributor Author

Yes.

@ramaraochavali
Copy link
Contributor Author

@costinm @hzxuzhonghu Can you please approve if you don't have any further questions?

Copy link
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

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

few remaining issues:

  • please add the IP6 ranges as well to the doc - I bet users will forget to add them
  • I think we need more discussion if we want to add this here, or use the existing 'networks', which define the ranges of pods in each internal network.

In a multi-network case the user shouldn't have to duplicate the ranges both here and in networks. The networks also has the benefit that it is also associating the ranges with network names, so I would prefer that - we can get the same behavior you have here by setting the fromRanges on the 'default' network with no API changes.

@@ -1088,8 +1088,12 @@ message MeshConfig {
// Configuration of mTLS for traffic between workloads within the mesh.
TLSConfig mesh_mTLS = 63;

// List of CIDR ranges that are treated as internal. If unset, then RFC1918 / RFC4193
// IP addresses will be considered internal.
repeated string internal_addresses = 64;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for 'best practice' - it won't work otherwise... But I think if you add the ranges above it'll cover all the mesh.

@ramaraochavali
Copy link
Contributor Author

I think we need more discussion if we want to add this here, or use the existing 'networks', which define the ranges of pods in each internal network.

If we go down this path - we need to change https://github.com/istio/api/blob/master/mesh/v1alpha1/network.proto#L53 to repeated. If you are OK with that, I can change that as well

@@ -1088,8 +1088,18 @@ message MeshConfig {
// Configuration of mTLS for traffic between workloads within the mesh.
TLSConfig mesh_mTLS = 63;

// List of CIDR ranges that are treated as internal. If unset, then RFC1918 / RFC4193
Copy link
Member

Choose a reason for hiding this comment

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

can you explain in the comments what the implications of "internal" are?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

// List of CIDR ranges that are treated as internal. If unset, then RFC1918 / RFC4193
// IP addresses will be considered internal.
// RFC 1918 defines the following address ranges as private,
// 10.0. 0.0/8 (addresses 10.0. 0.0 through 10.255. 255.255 inclusive)
Copy link
Member

Choose a reason for hiding this comment

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

nit: weird spacing in the IPs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah. Copied from RFC. Will correct

@costinm
Copy link
Contributor

costinm commented Apr 8, 2022 via email

@ramaraochavali
Copy link
Contributor Author

ramaraochavali commented Apr 9, 2022

@costinm My preference would be to leave it here as it s mesh wide config and people running with single network do not have to worry about additional network config + even if we network it needs an API change. But I see your point about redundancy, but I expect people who use it for multi network cases, do not have to worry about it. And I am not sure where/how that from_cidr is used.
@howardjohn WDYT?

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@costinm
Copy link
Contributor

costinm commented Apr 9, 2022 via email

@nrjpoddar
Copy link
Member

Are we still adding fields to MeshConfig or have frozen it to provide a way to migrate to the CRD?

@ramaraochavali
Copy link
Contributor Author

This is not for proxyConfig - Are you thinking it is for proxy config?

@costinm
Copy link
Contributor

costinm commented Apr 11, 2022 via email

@ramaraochavali
Copy link
Contributor Author

@costinm @howardjohn Please let me know your preference - I want to move forward with one way or other. I am not fully familiar with network use cases so I am good with what you think is best place to put this. But I would like to add API support for this

@costinm
Copy link
Contributor

costinm commented Apr 26, 2022

My preference remains to use networks. It may not even require any API change - just a flag/env variable in Istiod to indicate that networks will be used to trigger this behavior.

User will have to configure a network ('default') with all the ranges. They may also configured additional networks. All defined networks will be treated as internal, if this flag is set.

@ramaraochavali
Copy link
Contributor Author

I am fine with that.

@howardjohn Are you good with that as well?

@ramaraochavali
Copy link
Contributor Author

Closing this in-favour of istio/istio#38801

@ramaraochavali ramaraochavali deleted the fix/internal_addresses branch May 10, 2022 09:36
@costinm
Copy link
Contributor

costinm commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. 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.

8 participants