-
Notifications
You must be signed in to change notification settings - Fork 5.3k
bootstrap extension: internal listener #19467
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
Merged
Merged
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
c00cc79
wip
lambdai e037f8e
stash client conn fac
lambdai 9ede26a
make it build
lambdai 14ae9dc
format
lambdai 3758571
adding int conn factory test
lambdai ac32344
basic internal connection factory test
lambdai d8907d1
Merge branch 'main' into privintfactory
lambdai 3eb8f16
add default client connection factory
lambdai b94abcb
adding getFactoryByAddressType
lambdai 85e3a73
Revert "adding getFactoryByAddressType"
lambdai 2adc021
client connection factory follows UntypedFactory
lambdai c22906c
Merge branch 'main' into privintfactory
lambdai bcb375b
fix after merge
lambdai 83c193d
fix gcc switch enum
lambdai a932479
clang-tidy and better name
lambdai a42efa6
renaming
lambdai 4caa42b
tidy
lambdai 17afcba
add internal listener registry as bootstrap extension
lambdai f67542a
introduce singleton helper to create bind tls internal listener registry
lambdai 13a7c6c
see failure on singleton: singleton should be only used in main thread
lambdai 7bbc650
produce and save InternalListenerRegistry in extension factory
lambdai c987df4
bind tls_registry in ClientConnectionFactoryTest
lambdai 98e8099
remove singleton dep from conn handler
lambdai 476b44b
better conn lib
lambdai 0b5b1aa
more clean up
lambdai 2c87946
Merge branch 'main' into intlisbootstrapext
lambdai 7aad437
format
lambdai 5c430e6
pedantic
lambdai 2fc0854
intialize internal listener registry before server is intialized
lambdai abc3efe
fill an envoy internal source address
lambdai 13c7a52
clang_tidy
lambdai fbe3e73
set default 1MB buffer size for user space handle in connection factory
lambdai ee2d67f
category and add TODO
lambdai e9bd554
move addressType into address instance
lambdai cc8efbc
define api for internal connection registry
lambdai 7f319d4
add missing BUILD file in git
lambdai e4894cd
amend api
lambdai 6882c0c
proto comment, cont
lambdai 35fb6fd
more comments
lambdai c7688e9
Merge branch 'main' into intlisbootstrapext
lambdai c41de72
rename
lambdai e9c348c
rename, cont
lambdai 33b11e5
add boostrap.internal_listener_registry extension
lambdai 6e74d42
address doc comment
lambdai 60564c9
fix
lambdai ebece64
rewrite doc
lambdai d8788c2
fix api/BUILD and doc
lambdai 3b76567
again in bootstrap.rst
lambdai b600a45
revert unrelated jwt config
lambdai 812d19d
fix include
lambdai 77726ce
update test
lambdai 87047ac
improve coverage
lambdai 703bc19
add missing file
lambdai f2ab3b7
clean up header
lambdai 1ba722e
clangtidy
lambdai 63a5cf2
add an example envoy static config and real world use case
lambdai 6f8a9b2
format
lambdai fb1305b
renaming
lambdai 068944b
move inline config to another file, address all htuch's comments
lambdai e52ebc9
format pre
lambdai 6597235
revert the verifiable config
lambdai fa94013
move internal listener integration test to extension
lambdai 946cdb1
fix doc per phlax
lambdai 1e45353
merge main and fix conflict
lambdai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. | ||
|
|
||
| load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") | ||
|
|
||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| api_proto_package( | ||
| deps = [ | ||
| "@com_github_cncf_udpa//udpa/annotations:pkg", | ||
| "@com_github_cncf_udpa//xds/annotations/v3:pkg", | ||
| ], | ||
| ) |
22 changes: 22 additions & 0 deletions
22
api/envoy/extensions/bootstrap/internal_listener/v3/internal_listener.proto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package envoy.extensions.bootstrap.internal_listener.v3; | ||
|
|
||
| import "xds/annotations/v3/status.proto"; | ||
|
|
||
| import "udpa/annotations/status.proto"; | ||
|
|
||
| option java_package = "io.envoyproxy.envoy.extensions.bootstrap.internal_listener.v3"; | ||
| option java_outer_classname = "InternalListenerProto"; | ||
| option java_multiple_files = true; | ||
| option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/bootstrap/internal_listener/v3;internal_listenerv3"; | ||
| option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
| option (xds.annotations.v3.file_status).work_in_progress = true; | ||
|
|
||
| // [#protodoc-title: Internal Listener] | ||
| // Internal Listener :ref:`overview <config_internal_listener>`. | ||
| // [#extension: envoy.bootstrap.internal_listener] | ||
|
|
||
| // Configuration for internal listener. | ||
| message InternalListener { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
docs/root/configuration/other_features/internal_listener.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| .. _config_internal_listener: | ||
|
|
||
| Internal Listener | ||
| ================= | ||
|
|
||
| How it works | ||
| ------------ | ||
|
|
||
| This extension contains 2 major components to add a listener with | ||
| an :ref:`Envoy internal address <envoy_v3_api_msg_config.core.v3.EnvoyInternalAddress>` | ||
| and to create a client connection to that :ref:`listener <envoy_v3_api_msg_config.listener.v3.Listener>` | ||
|
|
||
| envoy.bootstrap.internal_listener | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| This bootstrap extension is required to support looking up the target listener via an | ||
| :ref:`envoy internal address <envoy_v3_api_msg_config.core.v3.EnvoyInternalAddress>` on each worker threads. | ||
lambdai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| network.connection.client.envoy_internal | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| It is a client connection factory. The factory is implicitly instantiated by the dispatcher to establish a client connection to an | ||
| internal listener address. This client connection factory is installed automatically when ``envoy.bootstrap.internal_listener`` is specified. | ||
|
|
||
| Example config | ||
| -------------- | ||
| Below is a smallest static config that redirect TCP proxy on port 19000 to the TCP proxy binding to the internal address. | ||
|
|
||
| .. code-block:: yaml | ||
lambdai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static_resources: | ||
| listeners: | ||
| - name: outbound_tcp_svc_19000 | ||
| address: | ||
| socket_address: | ||
| address: 0.0.0.0 | ||
| port_value: 19000 | ||
| filter_chains: | ||
| - filters: | ||
| - name: tcp_proxy | ||
| typed_config: | ||
| "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy | ||
| cluster: bridge_internal_listener | ||
| stat_prefix: svc_tcp_proxy | ||
| - name: singleton_internal_encap | ||
| address: | ||
| envoy_internal_address: | ||
| server_listener_name: singleton_internal_encap | ||
| filter_chains: | ||
| - filters: | ||
| - name: tcp_proxy | ||
| typed_config: | ||
| "@type": type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy | ||
| cluster: singleton_internal_encap | ||
| stat_prefix: encap_tcp_proxy | ||
| clusters: | ||
| - name: bridge_internal_listener | ||
| connect_timeout: 3600s | ||
| type: STATIC | ||
| load_assignment: | ||
| cluster_name: "bridge_internal_listener" | ||
| endpoints: | ||
| - lb_endpoints: | ||
| - endpoint: | ||
| address: | ||
| envoy_internal_address: | ||
| server_listener_name: singleton_internal_encap | ||
| transport_socket: | ||
| name: envoy.transport_sockets.raw_buffer | ||
| typed_config: | ||
| "@type": type.googleapis.com/envoy.extensions.transport_sockets.raw_buffer.v3.RawBuffer | ||
| - name: singleton_internal_encap | ||
| connect_timeout: 3600s | ||
| type: STATIC | ||
| load_assignment: | ||
| cluster_name: "singleton_internal_encap" | ||
| endpoints: | ||
| - lb_endpoints: | ||
| - endpoint: | ||
| address: | ||
| socket_address: | ||
| address: 0.0.0.0 | ||
| port_value: 19001 | ||
| bootstrap_extensions: | ||
| - name: envoy.bootstrap.internal_listener | ||
| typed_config: | ||
| "@type": "type.googleapis.com/envoy.extensions.bootstrap.internal_listener.v3.InternalListener" | ||
| layered_runtime: | ||
| layers: | ||
| - name: enable_internal_address | ||
| static_layer: | ||
| envoy.reloadable_features.internal_address: true | ||
|
|
||
| Real world use cases | ||
| -------------------- | ||
|
|
||
| Encap HTTP GET requests in a HTTP CONNECT request | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Currently Envoy :ref:`HTTP connection manager <config_http_conn_man>` | ||
| cannot proxy a GET request in an upstream HTTP CONNECT request. This requirement | ||
| can be acomplished by setting up the upstream endpoint of HTTP connection manager to the internal listener address. | ||
| Meanwhile, another internal listener binding to the above listener address includes a TCP proxy with :ref:`tunneling config <envoy_v3_api_field_extensions.filters.network.tcp_proxy.v3.TcpProxy.tunneling_config>`. | ||
|
|
||
| Decap the CONNECT requests | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| There are some complicated GET-in-CONNECT requests across services or edges. | ||
| In order to proxy the GET request within Envoy, two layer of :ref:`HTTP connection manager <config_http_conn_man>` | ||
| is demanded. The first HHTTP connection manager layer extract the TCP stream from a CONNECT request and redirect the TCP stream to the second | ||
| HTTP connection manager layer to parse the common GET requests. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ Other features | |
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| internal_listener | ||
| rate_limit | ||
| vcl | ||
| wasm | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/config/typed_config.h" | ||
| #include "envoy/network/address.h" | ||
| #include "envoy/network/connection.h" | ||
| #include "envoy/network/listen_socket.h" | ||
| #include "envoy/network/transport_socket.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Network { | ||
|
|
||
| // The factory to create a client connection. This factory hides the details of various remote | ||
| // address type and transport socket. | ||
| class ClientConnectionFactory : public Config::UntypedFactory { | ||
| public: | ||
| ~ClientConnectionFactory() override = default; | ||
|
|
||
| // Config::UntypedFactory | ||
| std::string category() const override { return "network.connection.client"; } | ||
|
|
||
| /** | ||
| * @param address The target remote address. | ||
| * @param source_address Optional source address. | ||
| * @param transport_socket The transport socket which supports this client connection. | ||
| * @param options The optional socket options. | ||
| * @return Network::ClientConnectionPtr The created connection. It's never nullptr but the return | ||
| * connection may be closed upon return. | ||
| */ | ||
| virtual Network::ClientConnectionPtr | ||
| createClientConnection(Event::Dispatcher& dispatcher, | ||
| Network::Address::InstanceConstSharedPtr address, | ||
| Network::Address::InstanceConstSharedPtr source_address, | ||
| Network::TransportSocketPtr&& transport_socket, | ||
| const Network::ConnectionSocket::OptionsSharedPtr& options) PURE; | ||
| }; | ||
|
|
||
| } // namespace Network | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.