-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
examples: Add dynamic configuration (control plane) sandbox #13746
Merged
mattklein123
merged 48 commits into
envoyproxy:master
from
phlax:examples-dynamic-configuration
Oct 28, 2020
Merged
Changes from 20 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
16da2b0
examples: Add wait_for utility function
phlax 441b4f7
add docs
phlax e687cea
examples: Add dynamic configuration example
phlax c03da09
verify
phlax c1e8b45
add resource.go
phlax 0b787c3
docs/
phlax 7bab9e9
examples/
phlax daca281
docs/
phlax 2b333ec
docs/
phlax 56e539f
example
phlax 034e547
example
phlax 8ee1637
examples/
phlax 0e98260
examples/
phlax 7af06c9
docs/
phlax e785cc4
docs/
phlax 7f23b70
docs/
phlax 90f2b67
docs/
phlax 25c44b7
docs/
phlax e299084
docs/
phlax e2eccd1
examples/
phlax c403196
docs/
phlax 151b4c7
docs/
phlax c487ca9
docs/
phlax 42985e7
examples/
phlax c1ae8d2
resource.go
phlax 983ea43
examples/
phlax cfbae81
examples
phlax 6d6d066
docs/
phlax 8b09bce
envoy.yaml
phlax 63048d4
rename dynamic-configuration -> dynamic-config-cp
phlax a1da617
docs/
phlax 5da4d84
Merge branch 'master' into examples-dynamic-configuration
phlax dcb9756
Merge branch 'master' into examples-dynamic-configuration
phlax 8cf7656
docs/
phlax bd31689
docs/
phlax 78ea83f
examples/
phlax cff56c2
examples/
phlax 1c21269
docs/
phlax 2d3795e
docs/
phlax 4661f92
docs/
phlax 61e289e
docs/
phlax 3fb94c1
examples/
phlax eefc0ad
docs/
phlax cf714f0
docs/
phlax e0cab03
docs/
phlax 3d582e8
remove host rewrite
phlax 5f9d732
docs/
phlax 328c40f
docs/
phlax 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
32 changes: 32 additions & 0 deletions
32
.../root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters.json
This file contains 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,32 @@ | ||
[ | ||
{ | ||
"version_info": "1", | ||
"cluster": { | ||
"@type": "type.googleapis.com/envoy.config.cluster.v3.Cluster", | ||
"name": "example_proxy_cluster", | ||
"type": "LOGICAL_DNS", | ||
"connect_timeout": "5s", | ||
"dns_lookup_family": "V4_ONLY", | ||
"load_assignment": { | ||
"cluster_name": "example_proxy_cluster", | ||
"endpoints": [ | ||
{ | ||
"lb_endpoints": [ | ||
{ | ||
"endpoint": { | ||
"address": { | ||
"socket_address": { | ||
"address": "service1", | ||
"port_value": 8080 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"last_updated": "2020-10-25T20:37:05.838Z" | ||
} | ||
] |
31 changes: 31 additions & 0 deletions
31
docs/root/start/sandboxes/_include/dynamic-configuration/response-config-cluster.json
This file contains 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,31 @@ | ||
[ | ||
{ | ||
"cluster": { | ||
"@type": "type.googleapis.com/envoy.api.v2.Cluster", | ||
"name": "xds_cluster", | ||
"type": "STRICT_DNS", | ||
"connect_timeout": "1s", | ||
"http2_protocol_options": {}, | ||
"load_assignment": { | ||
"cluster_name": "xds_cluster", | ||
"endpoints": [ | ||
{ | ||
"lb_endpoints": [ | ||
{ | ||
"endpoint": { | ||
"address": { | ||
"socket_address": { | ||
"address": "go-control-plane", | ||
"port_value": 18000 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"last_updated": "2020-10-25T20:20:54.897Z" | ||
} | ||
] |
This file contains 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,175 @@ | ||
.. _install_sandboxes_dynamic_configuration: | ||
|
||
Dynamic configuration | ||
===================== | ||
|
||
.. include:: _include/docker-env-setup.rst | ||
|
||
|
||
Step 3: Take a look at the proxy config | ||
*************************************** | ||
phlax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. literalinclude:: _include/dynamic-configuration/envoy.yaml | ||
:language: yaml | ||
|
||
Step 4: Start the proxy container | ||
********************************* | ||
|
||
First lets build our containers and start the proxy container, and two backend HTTP echo servers. | ||
|
||
The go-control-plane has not yet been started. | ||
|
||
.. code-block:: console | ||
|
||
$ pwd | ||
envoy/examples/dynamic-configuration | ||
$ docker-compose build --pull | ||
$ docker-compose up -d proxy | ||
$ docker-compose ps | ||
|
||
Name Command State Ports | ||
------------------------------------------------------------------------------------------------------------------------------ | ||
dynamic-configuration_proxy_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp, 0.0.0.0:19000->19000/tcp | ||
dynamic-configuration_service1_1 /bin/echo-server Up 8080/tcp | ||
dynamic-configuration_service2_1 /bin/echo-server Up 8080/tcp | ||
|
||
Step 4: Check web response | ||
************************** | ||
|
||
Nothing is responding on port 10000 | ||
|
||
.. code-block:: console | ||
|
||
$ curl http://localhost:10000 | ||
curl: (56) Recv failure: Connection reset by peer | ||
|
||
If we config dump the ``static_clusters`` we should see the ``xds_cluster`` we configured for the control | ||
plane: | ||
|
||
.. code-block:: console | ||
|
||
$ curl -s http://localhost:19000/config_dump | jq '.configs[1].static_clusters' | ||
|
||
.. literalinclude:: _include/dynamic-configuration/response-config-cluster.json | ||
:language: json | ||
|
||
Step 5: Start the go-control-plane | ||
********************************** | ||
|
||
Let's start up the go-control-plane. | ||
|
||
You may need to wait a moment or two for the service to become ``healthy``. | ||
|
||
.. code-block:: console | ||
|
||
$ docker-compose up --build -d go-control-plane | ||
$ docker-compose ps | ||
|
||
Name Command State Ports | ||
----------------------------------------------------------------------------------------------------------------------------------------- | ||
dynamic-configuration_go-control-plane_1 bin/example -debug Up (healthy) | ||
dynamic-configuration_proxy_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp, 0.0.0.0:19000->19000/tcp | ||
dynamic-configuration_service1_1 /bin/echo-server Up 8080/tcp | ||
dynamic-configuration_service2_1 /bin/echo-server Up 8080/tcp | ||
|
||
Step 5: Query the proxy | ||
*********************** | ||
|
||
Once the control plane has started, we should be able to make a request to port ``10000``, which will be | ||
served by ``service1``. | ||
|
||
.. code-block:: console | ||
|
||
$ curl http://localhost:10000 | ||
Request served by service1 | ||
|
||
HTTP/1.1 GET / | ||
|
||
Host: service1 | ||
Accept: */* | ||
X-Forwarded-Proto: http | ||
X-Request-Id: 1d93050e-f39c-4602-90f8-a124d6e78d26 | ||
X-Envoy-Expected-Rq-Timeout-Ms: 15000 | ||
Content-Length: 0 | ||
User-Agent: curl/7.72.0 | ||
|
||
Step 5: Dump the proxy config again | ||
*********************************** | ||
|
||
If we now ``config_dump`` the ``dynamic_active_clusters`` we should see the endpoint pointing | ||
to ``service1`` | ||
|
||
.. code-block:: console | ||
|
||
$ curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' | ||
|
||
.. literalinclude:: _include/dynamic-configuration/response-config-active-clusters.json | ||
:language: json | ||
|
||
Step 5: Stop the go-control-plane | ||
********************************* | ||
|
||
Let's stop the go-control-plane: | ||
|
||
.. code-block:: console | ||
|
||
$ docker-compose stop go-control-plane | ||
|
||
The Envoy proxy should continue proxying responses from ``service1`` | ||
|
||
.. code-block:: console | ||
|
||
$ curl http://localhost:10000 | grep "served by" | ||
Request served by service1 | ||
|
||
Step 5: Edit resource.go and restart the go-control-plane | ||
********************************************************* | ||
|
||
The example go-control-plane is started with a custom resource.go file which | ||
specifies the configuration provided to Envoy. | ||
|
||
If you edit this file and change the ``UpstreamHost`` from ``service1`` to ``service2``: | ||
|
||
.. literalinclude:: _include/dynamic-configuration/resource.go | ||
:language: go | ||
:lines: 33-40 | ||
:emphasize-lines: 6 | ||
:linenos: | ||
|
||
Further down in this file you must also change the configuration snapshot | ||
version number from ``"1"`` to ``"2"``: | ||
|
||
.. literalinclude:: _include/dynamic-configuration/resource.go | ||
:language: go | ||
:lineno-start: 167 | ||
:lines: 167-177 | ||
:emphasize-lines: 3 | ||
:linenos: | ||
|
||
Now rebuild and restart the go-control-plane: | ||
|
||
.. code-block:: console | ||
|
||
$ docker-compose up --build -d go-control-plane | ||
|
||
You may need to wait a moment or two for the go-control-plane to become ``healthy``. | ||
|
||
Step 5: Query the proxy | ||
*********************** | ||
|
||
When you make | ||
|
||
.. code-block:: console | ||
|
||
$ curl http://localhost:10000 | ||
Request served by service2 | ||
|
||
HTTP/1.1 GET / | ||
|
||
Host: service1 | ||
phlax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Accept: */* | ||
X-Forwarded-Proto: http | ||
X-Request-Id: 1d93050e-f39c-4602-90f8-a124d6e78d26 | ||
X-Envoy-Expected-Rq-Timeout-Ms: 15000 | ||
Content-Length: 0 | ||
User-Agent: curl/7.72.0 |
This file contains 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 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 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,7 @@ | ||
FROM golang | ||
|
||
RUN apt-get -y update && apt-get install -y -qq --no-install-recommends netcat | ||
RUN git clone https://github.com/envoyproxy/go-control-plane | ||
ADD ./resource.go /go/go-control-plane/internal/example/resource.go | ||
RUN cd go-control-plane && make bin/example | ||
WORKDIR /go/go-control-plane |
This file contains 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,6 @@ | ||
FROM envoyproxy/envoy-dev:latest | ||
|
||
RUN apt-get -y update && apt-get install -y -qq --no-install-recommends netcat | ||
COPY ./envoy.yaml /etc/envoy.yaml | ||
RUN chmod go+r /etc/envoy.yaml | ||
CMD ["/usr/local/bin/envoy", "-c /etc/envoy.yaml", "-l", "debug"] |
This file contains 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,2 @@ | ||
To learn about this sandbox and for instructions on how to run it please head over | ||
to the [Envoy docs](https://www.envoyproxy.io/docs/envoy/latest/start/sandboxes/postgres.html). | ||
phlax marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains 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,29 @@ | ||
version: "3.7" | ||
services: | ||
|
||
proxy: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile-proxy | ||
depends_on: | ||
- service1 | ||
- service2 | ||
ports: | ||
- 10000:10000 | ||
- 19000:19000 | ||
|
||
service1: | ||
image: jmalloc/echo-server | ||
hostname: service1 | ||
|
||
service2: | ||
image: jmalloc/echo-server | ||
hostname: service2 | ||
|
||
go-control-plane: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile-control-plane | ||
command: bin/example -debug | ||
healthcheck: | ||
test: nc -zv localhost 18000 |
This file contains 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,53 @@ | ||
admin: | ||
access_log_path: /dev/null | ||
address: | ||
socket_address: | ||
address: 0.0.0.0 | ||
port_value: 19000 | ||
|
||
dynamic_resources: | ||
ads_config: | ||
api_type: GRPC | ||
transport_api_version: V3 | ||
grpc_services: | ||
- envoy_grpc: | ||
cluster_name: xds_cluster | ||
set_node_on_first_message_only: false | ||
phlax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cds_config: | ||
resource_api_version: V3 | ||
ads: {} | ||
lds_config: | ||
resource_api_version: V3 | ||
ads: {} | ||
node: | ||
cluster: test-cluster | ||
id: test-id | ||
static_resources: | ||
clusters: | ||
- connect_timeout: 1s | ||
type: strict_dns | ||
load_assignment: | ||
cluster_name: xds_cluster | ||
endpoints: | ||
- lb_endpoints: | ||
- endpoint: | ||
address: | ||
socket_address: | ||
address: go-control-plane | ||
port_value: 18000 | ||
http2_protocol_options: {} | ||
name: xds_cluster | ||
layered_runtime: | ||
layers: | ||
- name: runtime-0 | ||
rtds_layer: | ||
rtds_config: | ||
resource_api_version: V3 | ||
ads: {} | ||
name: runtime-0 | ||
- name: runtime-1 | ||
rtds_layer: | ||
rtds_config: | ||
resource_api_version: V3 | ||
ads: {} | ||
name: runtime-1 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the wrong response - update to v3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm - seems like this is the response you get back from the go-control-plane
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess this must be what is configured in
static_resources
- im surprised its not anapi.v3.Cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I would update to v3 if possible. cc @htuch @kyessenov for guidance here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like an issue with go-control-plane - (at least the example i based this on)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, i reckon its not gcp thats returning this, its what you get from config above, when you do config_dump in envoy - its the static part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK not sure what the issue is without digging in more detail. It's possible this is a config dump issue. I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me open a ticket - and we can thrash it out there...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phlax Can you help me with the gcp samples you followed? From the initial pass looks like gcp example uses v3 https://github.com/envoyproxy/go-control-plane/blob/master/internal/example/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jyotimahapatra i think its not a problem with go-control-plane
i opened a ticket here #13817 to raise it