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 port ranges in opaque ports environment variable #2080

Closed
wants to merge 2 commits into from

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Dec 21, 2022

Depends on #2079

Currently, the LINKERD2_PROXY_INBOUND_PORTS_DISABLE_PROTOCOL_DETECTION
environment variable accepts a comma-delimited list of individual port
numbers. Each of these ports is then stored as a separate cache entry in
the port policy cache to indicate that the port is opaque.

Unfortunately, this does not work well when a very large number of ports
are marked as opaque, because the proxy-injector will generate a massive
value for that environment variable, listing every individual port. This
can cause issues when this manifest becomes larger than the Kubernetes
API can reasonably handle. In addition, huge numbers of ports will all
be kept in memory as a separate cache entry by the proxy, increasing
proxy memory usage. See linkerd/linkerd2#9803 for details.

This branch changes the proxy so that the
LINKERD2_PROXY_INBOUND_PORTS_DISABLE_PROTOCOL_DETECTION environment
variable may contain a list of individual port numbers and port
ranges, which are specified as <low>-<high>.

Opaque ports are now stored using a RangeInclusiveSet from the
rangemap crate, rather than by creating individual cache entries for
each port. This means we are no longer storing a separate entry in the
cache for every port in a range, reducing memory consumption when there
are very large ranges of opaque ports.

This is the proxy half of the work towards resolving
linkerd/linkerd2#9803. Once this branch lands, we'll also have to change
the proxy-injector so that it no longer handles opaque port ranges by
generating a list of all the individual ports in the range, and simply
forwards those ranges as they were specified when generating the
environment variable.

@hawkw hawkw requested a review from a team as a code owner December 21, 2022 21:16
Depends on #2079

Currently, the `LINKERD2_PROXY_INBOUND_PORTS_DISABLE_PROTOCOL_DETECTION`
environment variable accepts a comma-delimited list of individual port
numbers. Each of these ports is then stored as a separate cache entry in
the port policy cache to indicate that the port is opaque.

Unfortunately, this does not work well when a very large number of ports
are marked as opaque, because the proxy-injector will generate a massive
value for that environment variable, listing every individual port. This
can cause issues when this manifest becomes larger than the Kubernetes
API can reasonably handle. In addition, huge numbers of ports will all
be kept in memory as a separate cache entry by the proxy, increasing
proxy memory usage. See linkerd/linkerd2#9803 for details.

This branch changes the proxy so that the
`LINKERD2_PROXY_INBOUND_PORTS_DISABLE_PROTOCOL_DETECTION` environment
variable may contain a list of individual port numbers *and* port
ranges, which are specified as `<low>-<high>`.

Opaque ports are now stored using a `RangeInclusiveSet` from the
`rangemap` crate, rather than by creating individual cache entries for
each port. This means we are no longer storing a separate entry in the
cache for every port in a range, reducing memory consumption when there
are very large ranges of opaque ports.

This is the proxy half of the work towards resolving
linkerd/linkerd2#9803. Once this branch lands, we'll also have to change
the proxy-injector so that it no longer handles opaque port ranges by
generating a list of all the individual ports in the range, and simply
forwards those ranges as they were specified when generating the
environment variable.
Self::new(cache, default, Some(discover), opaque_ports)
}

fn new(
Copy link
Member

Choose a reason for hiding this comment

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

Prefer to make it clear it spawns things.

Suggested change
fn new(
fn spawn(

@olix0r olix0r marked this pull request as draft December 28, 2022 18:04
@hawkw hawkw closed this Feb 22, 2023
@olix0r olix0r deleted the eliza/port-ranges branch March 7, 2023 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants