From 16da2b0fd253999c0372c2e2110277b8c4729d4c Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 15:30:49 +0000 Subject: [PATCH 01/46] examples: Add wait_for utility function Signed-off-by: Ryan Northey --- examples/verify-common.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/verify-common.sh b/examples/verify-common.sh index 917ec952fd08..509faf3a846f 100644 --- a/examples/verify-common.sh +++ b/examples/verify-common.sh @@ -115,6 +115,20 @@ responds_without_header () { } } +wait_for () { + local i=1 returns=1 seconds="$1" + shift + while ((i<=seconds)); do + if "$@"; then + returns=0 + break + else + sleep 1 + ((i++)) + fi + done + return "$returns" +} trap 'cleanup' EXIT From 441b4f7438bc5508a6c8a72ef2b08664e9b9c898 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 15:37:34 +0000 Subject: [PATCH 02/46] add docs Signed-off-by: Ryan Northey --- examples/DEVELOPER.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/DEVELOPER.md b/examples/DEVELOPER.md index 1538d1f605f9..634137156841 100644 --- a/examples/DEVELOPER.md +++ b/examples/DEVELOPER.md @@ -109,6 +109,17 @@ responds_without_header \ `responds_without_header` can accept additional curl arguments like `responds_with` +#### Utility functions: `wait_for` + +You can wait for some amount of time for a command to return 0 + +The following example will wait for 20 seconds for a service ``my-service`` to become +healthy. + +```bash +wait_for 20 sh -c "docker-compose ps my-service | grep healthy | grep -v unhealthy" +``` + ### Slow starting `docker` compositions Unless your example provides a way for ensuring that all containers are healthy by From e687ceac291c6fd310ac9cb08fd4bcefc52247d5 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sat, 24 Oct 2020 16:37:55 +0100 Subject: [PATCH 03/46] examples: Add dynamic configuration example Signed-off-by: Ryan Northey --- .../Dockerfile-control-plane | 4 ++ .../dynamic-configuration/Dockerfile-proxy | 5 ++ examples/dynamic-configuration/README.md | 2 + .../dynamic-configuration/docker-compose.yaml | 29 ++++++++++ examples/dynamic-configuration/envoy.yaml | 53 +++++++++++++++++++ examples/dynamic-configuration/verify.sh | 48 +++++++++++++++++ 6 files changed, 141 insertions(+) create mode 100644 examples/dynamic-configuration/Dockerfile-control-plane create mode 100644 examples/dynamic-configuration/Dockerfile-proxy create mode 100644 examples/dynamic-configuration/README.md create mode 100644 examples/dynamic-configuration/docker-compose.yaml create mode 100644 examples/dynamic-configuration/envoy.yaml create mode 100755 examples/dynamic-configuration/verify.sh diff --git a/examples/dynamic-configuration/Dockerfile-control-plane b/examples/dynamic-configuration/Dockerfile-control-plane new file mode 100644 index 000000000000..93db4c7a5f63 --- /dev/null +++ b/examples/dynamic-configuration/Dockerfile-control-plane @@ -0,0 +1,4 @@ +FROM golang + +RUN git clone https://github.com/envoyproxy/go-control-plane +RUN cd go-control-plane && make bin/example diff --git a/examples/dynamic-configuration/Dockerfile-proxy b/examples/dynamic-configuration/Dockerfile-proxy new file mode 100644 index 000000000000..f70f44311461 --- /dev/null +++ b/examples/dynamic-configuration/Dockerfile-proxy @@ -0,0 +1,5 @@ +FROM envoyproxy/envoy-dev:latest + +COPY ./envoy.yaml /etc/envoy.yaml +RUN chmod go+r /etc/envoy.yaml +CMD ["/usr/local/bin/envoy", "-c /etc/envoy.yaml", "-l", "debug"] diff --git a/examples/dynamic-configuration/README.md b/examples/dynamic-configuration/README.md new file mode 100644 index 000000000000..346b020e98c8 --- /dev/null +++ b/examples/dynamic-configuration/README.md @@ -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). diff --git a/examples/dynamic-configuration/docker-compose.yaml b/examples/dynamic-configuration/docker-compose.yaml new file mode 100644 index 000000000000..8bdfcf01d376 --- /dev/null +++ b/examples/dynamic-configuration/docker-compose.yaml @@ -0,0 +1,29 @@ +version: "3.7" +services: + + example_proxy_cluster: + build: + context: . + dockerfile: Dockerfile-proxy + depends_on: + - go-control-plane + - service1 + - service2 + command: "/usr/local/bin/envoy -c /etc/envoy.yaml -l debug" + ports: + - 10000:10000 + - 19000:19000 + + service1: + image: jmalloc/echo-server + + service2: + image: jmalloc/echo-server + + go-control-plane: + build: + context: . + dockerfile: Dockerfile-control-plane + volumes: + - ./go-control-plane:/go/go-control-plane + command: bash -c "cd go-control-plane && bin/example" diff --git a/examples/dynamic-configuration/envoy.yaml b/examples/dynamic-configuration/envoy.yaml new file mode 100644 index 000000000000..f321cf2d1c98 --- /dev/null +++ b/examples/dynamic-configuration/envoy.yaml @@ -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: true + 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 diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-configuration/verify.sh new file mode 100755 index 000000000000..a2e76a4f363c --- /dev/null +++ b/examples/dynamic-configuration/verify.sh @@ -0,0 +1,48 @@ +#!/bin/bash -e + +export NAME=postgres +export DELAY=10 + +# shellcheck source=examples/verify-common.sh +. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh" + +_psql () { + local postgres_client + postgres_client=(docker run -i --rm --network envoymesh -e "PGSSLMODE=disable" postgres:latest psql -U postgres -h proxy -p 1999) + "${postgres_client[@]}" "${@}" +} + +DBNAME=testdb + +run_log "Create a postgres database" +_psql -c "CREATE DATABASE ${DBNAME};" +_psql -c '\l' | grep ${DBNAME} + +run_log "Create a postgres table" +_psql -d ${DBNAME} -c 'CREATE TABLE tbl ( f SERIAL PRIMARY KEY );' + +run_log "Insert some data" +_psql -d ${DBNAME} -c 'INSERT INTO tbl VALUES (DEFAULT);' + +run_log "Checking inserted data" +_psql -d ${DBNAME} -c 'SELECT * FROM tbl;' | grep -E '1$' + +run_log "Updating data" +_psql -d ${DBNAME} -c 'UPDATE tbl SET f = 2 WHERE f = 1;' + +run_log "Raise an exception for duplicate key violation" +_psql -d ${DBNAME} -c 'INSERT INTO tbl VALUES (DEFAULT);' 2>&1 | grep -A1 'duplicate key value violates unique constraint' + +run_log "Change some more data" +_psql -d ${DBNAME} -c 'DELETE FROM tbl;' +_psql -d ${DBNAME} -c 'INSERT INTO tbl VALUES (DEFAULT);' + +run_log "Check postgres egress stats" +responds_with \ + egress_postgres \ + "http://localhost:8001/stats?filter=egress_postgres" + +run_log "Check postgres TCP stats" +responds_with \ + postgres_tcp \ + "http://localhost:8001/stats?filter=postgres_tcp" From c03da09217ce48851523103594a22e81fc941f19 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sat, 24 Oct 2020 16:43:33 +0100 Subject: [PATCH 04/46] verify Signed-off-by: Ryan Northey --- examples/dynamic-configuration/verify.sh | 47 +----------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-configuration/verify.sh index a2e76a4f363c..d493f43863a7 100755 --- a/examples/dynamic-configuration/verify.sh +++ b/examples/dynamic-configuration/verify.sh @@ -1,48 +1,3 @@ #!/bin/bash -e -export NAME=postgres -export DELAY=10 - -# shellcheck source=examples/verify-common.sh -. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh" - -_psql () { - local postgres_client - postgres_client=(docker run -i --rm --network envoymesh -e "PGSSLMODE=disable" postgres:latest psql -U postgres -h proxy -p 1999) - "${postgres_client[@]}" "${@}" -} - -DBNAME=testdb - -run_log "Create a postgres database" -_psql -c "CREATE DATABASE ${DBNAME};" -_psql -c '\l' | grep ${DBNAME} - -run_log "Create a postgres table" -_psql -d ${DBNAME} -c 'CREATE TABLE tbl ( f SERIAL PRIMARY KEY );' - -run_log "Insert some data" -_psql -d ${DBNAME} -c 'INSERT INTO tbl VALUES (DEFAULT);' - -run_log "Checking inserted data" -_psql -d ${DBNAME} -c 'SELECT * FROM tbl;' | grep -E '1$' - -run_log "Updating data" -_psql -d ${DBNAME} -c 'UPDATE tbl SET f = 2 WHERE f = 1;' - -run_log "Raise an exception for duplicate key violation" -_psql -d ${DBNAME} -c 'INSERT INTO tbl VALUES (DEFAULT);' 2>&1 | grep -A1 'duplicate key value violates unique constraint' - -run_log "Change some more data" -_psql -d ${DBNAME} -c 'DELETE FROM tbl;' -_psql -d ${DBNAME} -c 'INSERT INTO tbl VALUES (DEFAULT);' - -run_log "Check postgres egress stats" -responds_with \ - egress_postgres \ - "http://localhost:8001/stats?filter=egress_postgres" - -run_log "Check postgres TCP stats" -responds_with \ - postgres_tcp \ - "http://localhost:8001/stats?filter=postgres_tcp" +export NAME=dynamic-configuration From c1e8b459bcc5c82d6bae89439584dbe6aeed5118 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sat, 24 Oct 2020 17:42:17 +0100 Subject: [PATCH 05/46] add resource.go Signed-off-by: Ryan Northey --- .../Dockerfile-control-plane | 3 + .../dynamic-configuration/docker-compose.yaml | 5 +- examples/dynamic-configuration/resource.go | 177 ++++++++++++++++++ 3 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 examples/dynamic-configuration/resource.go diff --git a/examples/dynamic-configuration/Dockerfile-control-plane b/examples/dynamic-configuration/Dockerfile-control-plane index 93db4c7a5f63..bbc29aa38fb0 100644 --- a/examples/dynamic-configuration/Dockerfile-control-plane +++ b/examples/dynamic-configuration/Dockerfile-control-plane @@ -1,4 +1,7 @@ FROM golang RUN git clone https://github.com/envoyproxy/go-control-plane +COPY ./resource.go /go/go-control-plane/internal/example/resource.go RUN cd go-control-plane && make bin/example +WORKDIR /go/go-control-plane +CMD ["/usr/local/bin/envoy", "-c", "/etc/envoy.yaml", "-l", "debug", "--service-cluster", "proxy"] diff --git a/examples/dynamic-configuration/docker-compose.yaml b/examples/dynamic-configuration/docker-compose.yaml index 8bdfcf01d376..555db0999009 100644 --- a/examples/dynamic-configuration/docker-compose.yaml +++ b/examples/dynamic-configuration/docker-compose.yaml @@ -9,7 +9,6 @@ services: - go-control-plane - service1 - service2 - command: "/usr/local/bin/envoy -c /etc/envoy.yaml -l debug" ports: - 10000:10000 - 19000:19000 @@ -24,6 +23,4 @@ services: build: context: . dockerfile: Dockerfile-control-plane - volumes: - - ./go-control-plane:/go/go-control-plane - command: bash -c "cd go-control-plane && bin/example" + command: make example diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-configuration/resource.go new file mode 100644 index 000000000000..ca0daf78a84a --- /dev/null +++ b/examples/dynamic-configuration/resource.go @@ -0,0 +1,177 @@ +// Copyright 2020 Envoyproxy Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package example + +import ( + "time" + + "github.com/golang/protobuf/ptypes" + + cluster "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" + core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" + endpoint "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" + listener "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" + route "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" + hcm "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" + "github.com/envoyproxy/go-control-plane/pkg/cache/types" + "github.com/envoyproxy/go-control-plane/pkg/cache/v3" + "github.com/envoyproxy/go-control-plane/pkg/resource/v3" + "github.com/envoyproxy/go-control-plane/pkg/wellknown" +) + +const ( + ClusterName = "example_proxy_cluster" + RouteName = "local_route" + ListenerName = "listener_0" + ListenerPort = 10000 + UpstreamHost = "service1" + UpstreamPort = 8080 +) + +func makeCluster(clusterName string) *cluster.Cluster { + return &cluster.Cluster{ + Name: clusterName, + ConnectTimeout: ptypes.DurationProto(5 * time.Second), + ClusterDiscoveryType: &cluster.Cluster_Type{Type: cluster.Cluster_LOGICAL_DNS}, + LbPolicy: cluster.Cluster_ROUND_ROBIN, + LoadAssignment: makeEndpoint(clusterName), + DnsLookupFamily: cluster.Cluster_V4_ONLY, + } +} + +func makeEndpoint(clusterName string) *endpoint.ClusterLoadAssignment { + return &endpoint.ClusterLoadAssignment{ + ClusterName: clusterName, + Endpoints: []*endpoint.LocalityLbEndpoints{{ + LbEndpoints: []*endpoint.LbEndpoint{{ + HostIdentifier: &endpoint.LbEndpoint_Endpoint{ + Endpoint: &endpoint.Endpoint{ + Address: &core.Address{ + Address: &core.Address_SocketAddress{ + SocketAddress: &core.SocketAddress{ + Protocol: core.SocketAddress_TCP, + Address: UpstreamHost, + PortSpecifier: &core.SocketAddress_PortValue{ + PortValue: UpstreamPort, + }, + }, + }, + }, + }, + }, + }}, + }}, + } +} + +func makeRoute(routeName string, clusterName string) *route.RouteConfiguration { + return &route.RouteConfiguration{ + Name: routeName, + VirtualHosts: []*route.VirtualHost{{ + Name: "local_service", + Domains: []string{"*"}, + Routes: []*route.Route{{ + Match: &route.RouteMatch{ + PathSpecifier: &route.RouteMatch_Prefix{ + Prefix: "/", + }, + }, + Action: &route.Route_Route{ + Route: &route.RouteAction{ + ClusterSpecifier: &route.RouteAction_Cluster{ + Cluster: clusterName, + }, + HostRewriteSpecifier: &route.RouteAction_HostRewriteLiteral{ + HostRewriteLiteral: UpstreamHost, + }, + }, + }, + }}, + }}, + } +} + +func makeHTTPListener(listenerName string, route string) *listener.Listener { + // HTTP filter configuration + manager := &hcm.HttpConnectionManager{ + CodecType: hcm.HttpConnectionManager_AUTO, + StatPrefix: "http", + RouteSpecifier: &hcm.HttpConnectionManager_Rds{ + Rds: &hcm.Rds{ + ConfigSource: makeConfigSource(), + RouteConfigName: route, + }, + }, + HttpFilters: []*hcm.HttpFilter{{ + Name: wellknown.Router, + }}, + } + pbst, err := ptypes.MarshalAny(manager) + if err != nil { + panic(err) + } + + return &listener.Listener{ + Name: listenerName, + Address: &core.Address{ + Address: &core.Address_SocketAddress{ + SocketAddress: &core.SocketAddress{ + Protocol: core.SocketAddress_TCP, + Address: "0.0.0.0", + PortSpecifier: &core.SocketAddress_PortValue{ + PortValue: ListenerPort, + }, + }, + }, + }, + FilterChains: []*listener.FilterChain{{ + Filters: []*listener.Filter{{ + Name: wellknown.HTTPConnectionManager, + ConfigType: &listener.Filter_TypedConfig{ + TypedConfig: pbst, + }, + }}, + }}, + } +} + +func makeConfigSource() *core.ConfigSource { + source := &core.ConfigSource{} + source.ResourceApiVersion = resource.DefaultAPIVersion + source.ConfigSourceSpecifier = &core.ConfigSource_ApiConfigSource{ + ApiConfigSource: &core.ApiConfigSource{ + TransportApiVersion: resource.DefaultAPIVersion, + ApiType: core.ApiConfigSource_GRPC, + SetNodeOnFirstMessageOnly: true, + GrpcServices: []*core.GrpcService{{ + TargetSpecifier: &core.GrpcService_EnvoyGrpc_{ + EnvoyGrpc: &core.GrpcService_EnvoyGrpc{ClusterName: "xds_cluster"}, + }, + }}, + }, + } + return source +} + +func GenerateSnapshot() cache.Snapshot { + return cache.NewSnapshot( + "1", + []types.Resource{}, // endpoints + []types.Resource{makeCluster(ClusterName)}, + []types.Resource{makeRoute(RouteName, ClusterName)}, + []types.Resource{makeHTTPListener(ListenerName, RouteName)}, + []types.Resource{}, // runtimes + []types.Resource{}, // secrets + ) +} From 0b787c3cbb91b80c3d8f130ef5254757dd797ec2 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sat, 24 Oct 2020 19:46:31 +0100 Subject: [PATCH 06/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration.rst | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 docs/root/start/sandboxes/dynamic-configuration.rst diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst new file mode 100644 index 000000000000..9d3844561b0a --- /dev/null +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -0,0 +1,113 @@ +.. _install_sandboxes_wasm_filter: + +Dynamic configuration +===================== + +.. include:: _include/docker-env-setup.rst + + +Step 3: Take a look at the proxy config +*************************************** + + +Step 4: Start the proxy container +********************************* + +First lets build our containers and start the proxy container, and two backend HTTP echo servers. + +.. code-block:: console + + $ pwd + envoy/examples/dynamic-configuration + $ docker-compose build --pull + $ docker-compose up -d proxy + $ docker-compose ps + + Name Command State Ports + ----------------------------------------------------------------------------------------------- + + +Step 4: Check web response +************************** + +Nothing is listening on 10000 + +.. code-block:: console + + $ curl http://localhost:10000 + curl: (56) Recv failure: Connection reset by peer + + +If we config dump the clusters we just 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' + [ + { + "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-24T18:30:55.458Z" + } + ] + + +Step 5: Start the go-control-plane +********************************** + +.. code-block:: console + + $ docker-compose up -d go-control-plane + $ docker-compose ps + + Name Command State Ports + ----------------------------------------------------------------------------------------------- + + +Step 5: Query the proxy +*********************** + + +Step 5: Dump the proxy config again +*********************************** + + +Step 5: Stop the go-control-plane +********************************* + + +Step 5: Query the proxy +*********************** + + +Step 5: Edit resource.go and restart the go-control-plane +********************************************************* + + +Step 5: Query the proxy +*********************** From 7bab9e957e9a29e79a2d21d6fa13e8c670ba0cb6 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sat, 24 Oct 2020 19:46:35 +0100 Subject: [PATCH 07/46] examples/ Signed-off-by: Ryan Northey --- .../dynamic-configuration/Dockerfile-control-plane | 2 +- examples/dynamic-configuration/Dockerfile-proxy | 1 + examples/dynamic-configuration/docker-compose.yaml | 5 +++-- examples/dynamic-configuration/verify.sh | 11 +++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/dynamic-configuration/Dockerfile-control-plane b/examples/dynamic-configuration/Dockerfile-control-plane index bbc29aa38fb0..3305d7ba57da 100644 --- a/examples/dynamic-configuration/Dockerfile-control-plane +++ b/examples/dynamic-configuration/Dockerfile-control-plane @@ -1,7 +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 COPY ./resource.go /go/go-control-plane/internal/example/resource.go RUN cd go-control-plane && make bin/example WORKDIR /go/go-control-plane -CMD ["/usr/local/bin/envoy", "-c", "/etc/envoy.yaml", "-l", "debug", "--service-cluster", "proxy"] diff --git a/examples/dynamic-configuration/Dockerfile-proxy b/examples/dynamic-configuration/Dockerfile-proxy index f70f44311461..6e1c4d08b6cb 100644 --- a/examples/dynamic-configuration/Dockerfile-proxy +++ b/examples/dynamic-configuration/Dockerfile-proxy @@ -1,5 +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"] diff --git a/examples/dynamic-configuration/docker-compose.yaml b/examples/dynamic-configuration/docker-compose.yaml index 555db0999009..812a8dc168f1 100644 --- a/examples/dynamic-configuration/docker-compose.yaml +++ b/examples/dynamic-configuration/docker-compose.yaml @@ -1,12 +1,11 @@ version: "3.7" services: - example_proxy_cluster: + proxy: build: context: . dockerfile: Dockerfile-proxy depends_on: - - go-control-plane - service1 - service2 ports: @@ -24,3 +23,5 @@ services: context: . dockerfile: Dockerfile-control-plane command: make example + healthcheck: + test: nc -zv localhost 18000 diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-configuration/verify.sh index d493f43863a7..bc6245d4e725 100755 --- a/examples/dynamic-configuration/verify.sh +++ b/examples/dynamic-configuration/verify.sh @@ -1,3 +1,14 @@ #!/bin/bash -e export NAME=dynamic-configuration + +# shellcheck source=examples/verify-common.sh +. "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh" + +# curl http://localhost:19000/config_dump + +curl http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' | grep null + +sleep 20 + +curl http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' From daca2810cb6f7a0c0fe2cd598ddd28c0f5a0208f Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sat, 24 Oct 2020 19:48:38 +0100 Subject: [PATCH 08/46] docs/ Signed-off-by: Ryan Northey --- docs/root/start/sandboxes/dynamic-configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index 9d3844561b0a..1de626f81a7f 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -1,4 +1,4 @@ -.. _install_sandboxes_wasm_filter: +.. _install_sandboxes_dynamic_configuration: Dynamic configuration ===================== From 2b333ece738f9741e76bcc9fb6b41cc947f4598a Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sat, 24 Oct 2020 20:02:58 +0100 Subject: [PATCH 09/46] docs/ Signed-off-by: Ryan Northey --- docs/root/start/sandboxes/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/root/start/sandboxes/index.rst b/docs/root/start/sandboxes/index.rst index 859145972cd4..8f9c4a5eb1d7 100644 --- a/docs/root/start/sandboxes/index.rst +++ b/docs/root/start/sandboxes/index.rst @@ -14,6 +14,7 @@ features. The following sandboxes are available: cache cors csrf + dynamic-configuration ext_authz fault_injection front_proxy From 56e539f9727d97a4dc6b7326f2575de543a632be Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 14:47:07 +0000 Subject: [PATCH 10/46] example Signed-off-by: Ryan Northey --- .../Dockerfile-control-plane | 2 +- .../dynamic-configuration/docker-compose.yaml | 4 +- examples/dynamic-configuration/envoy.yaml | 2 +- examples/dynamic-configuration/resource.go | 4 +- examples/dynamic-configuration/verify.sh | 64 ++++++++++++++++++- 5 files changed, 68 insertions(+), 8 deletions(-) diff --git a/examples/dynamic-configuration/Dockerfile-control-plane b/examples/dynamic-configuration/Dockerfile-control-plane index 3305d7ba57da..3c5bd17826ef 100644 --- a/examples/dynamic-configuration/Dockerfile-control-plane +++ b/examples/dynamic-configuration/Dockerfile-control-plane @@ -2,6 +2,6 @@ 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 -COPY ./resource.go /go/go-control-plane/internal/example/resource.go +ADD ./resource.go /go/go-control-plane/internal/example/resource.go RUN cd go-control-plane && make bin/example WORKDIR /go/go-control-plane diff --git a/examples/dynamic-configuration/docker-compose.yaml b/examples/dynamic-configuration/docker-compose.yaml index 812a8dc168f1..dde3bb3696bc 100644 --- a/examples/dynamic-configuration/docker-compose.yaml +++ b/examples/dynamic-configuration/docker-compose.yaml @@ -14,14 +14,16 @@ services: service1: image: jmalloc/echo-server + hostname: service1 service2: image: jmalloc/echo-server + hostname: service2 go-control-plane: build: context: . dockerfile: Dockerfile-control-plane - command: make example + command: bin/example -debug healthcheck: test: nc -zv localhost 18000 diff --git a/examples/dynamic-configuration/envoy.yaml b/examples/dynamic-configuration/envoy.yaml index f321cf2d1c98..f43e9ded7d12 100644 --- a/examples/dynamic-configuration/envoy.yaml +++ b/examples/dynamic-configuration/envoy.yaml @@ -12,7 +12,7 @@ dynamic_resources: grpc_services: - envoy_grpc: cluster_name: xds_cluster - set_node_on_first_message_only: true + set_node_on_first_message_only: false cds_config: resource_api_version: V3 ads: {} diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-configuration/resource.go index ca0daf78a84a..e6f54c94c381 100644 --- a/examples/dynamic-configuration/resource.go +++ b/examples/dynamic-configuration/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service1" + UpstreamHost = "service2" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "1", + "2", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-configuration/verify.sh index bc6245d4e725..24bb9847f47a 100755 --- a/examples/dynamic-configuration/verify.sh +++ b/examples/dynamic-configuration/verify.sh @@ -1,14 +1,72 @@ #!/bin/bash -e export NAME=dynamic-configuration +export UPARGS=" proxy" # shellcheck source=examples/verify-common.sh . "$(dirname "${BASH_SOURCE[0]}")/../verify-common.sh" -# curl http://localhost:19000/config_dump +run_log "Check port 10000 is not open (still shows as succeeded)" +nc -zv localhost 10000 |& grep -v open -curl http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' | grep null +run_log "Check there is no config for dynamic clusters" +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].dynamic_active_clusters // "NO_CLUSTERS"' \ + | grep NO_CLUSTERS + +run_log "Bring up go-control-plane" +docker-compose up --build -d go-control-plane sleep 20 -curl http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' +run_log "Check for response from service1 backend" +responds_with \ + "Request served by service1" \ + http://localhost:10000 + +run_log "Check config for active clusters" +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].dynamic_active_clusters' \ + | grep '"version_info": "1"' +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].dynamic_active_clusters' \ + | grep '"address": "service1"' + +run_log "Bring down the control plane" +docker-compose stop go-control-plane + +sleep 5 + +run_log "Check for continued response from service1 backend" +responds_with \ + "Request served by service1" \ + http://localhost:10000 + +run_log "Check config for active clusters" +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].dynamic_active_clusters' \ + | grep '"version_info": "1"' +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].dynamic_active_clusters' \ + | grep '"address": "service1"' + +run_log "Edit resource.go" +sed -i s/service1/service2/ resource.go +sed -i s/\"1\",/\"2\",/ resource.go + +run_log "Bring back up the control plane" +docker-compose up --build -d go-control-plane +sleep 20 + +run_log "Check for response from service2 backend" +responds_with \ + "Request served by service2" \ + http://localhost:10000 + +run_log "Check config for active clusters pointing to service2" +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].dynamic_active_clusters' \ + | grep '"version_info": "2"' +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].dynamic_active_clusters' \ + | grep '"address": "service2"' From 034e54782593641044f8ec0c56839d89c591372a Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 14:47:32 +0000 Subject: [PATCH 11/46] example Signed-off-by: Ryan Northey --- examples/dynamic-configuration/resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-configuration/resource.go index e6f54c94c381..ca0daf78a84a 100644 --- a/examples/dynamic-configuration/resource.go +++ b/examples/dynamic-configuration/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service2" + UpstreamHost = "service1" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "2", + "1", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, From 8ee16370a7017dd4d0d1a1036034789d5b16f3e9 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 15:30:02 +0000 Subject: [PATCH 12/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-configuration/resource.go | 4 ++-- examples/dynamic-configuration/verify.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-configuration/resource.go index ca0daf78a84a..e6f54c94c381 100644 --- a/examples/dynamic-configuration/resource.go +++ b/examples/dynamic-configuration/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service1" + UpstreamHost = "service2" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "1", + "2", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-configuration/verify.sh index 24bb9847f47a..5d9f51872167 100755 --- a/examples/dynamic-configuration/verify.sh +++ b/examples/dynamic-configuration/verify.sh @@ -17,7 +17,7 @@ curl -s http://localhost:19000/config_dump \ run_log "Bring up go-control-plane" docker-compose up --build -d go-control-plane -sleep 20 +wait_for 30 sh -c "docker-compose ps go-control-plane | grep healthy | grep -v unhealthy" run_log "Check for response from service1 backend" responds_with \ From 0e9826012f97edea17f60bd4fc10871b0051a3e3 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 15:42:14 +0000 Subject: [PATCH 13/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-configuration/resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-configuration/resource.go index e6f54c94c381..ca0daf78a84a 100644 --- a/examples/dynamic-configuration/resource.go +++ b/examples/dynamic-configuration/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service2" + UpstreamHost = "service1" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "2", + "1", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, From 7af06c945b34814c2f1da575671024333b70a04a Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 20:27:11 +0000 Subject: [PATCH 14/46] docs/ Signed-off-by: Ryan Northey --- .../response-config-cluster.json | 31 +++++++++++++++++ .../start/sandboxes/dynamic-configuration.rst | 33 ++----------------- 2 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 docs/root/start/sandboxes/_include/dynamic-configuration/response-config-cluster.json diff --git a/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-cluster.json b/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-cluster.json new file mode 100644 index 000000000000..9df9306e0f45 --- /dev/null +++ b/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-cluster.json @@ -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" + } +] diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index 1de626f81a7f..62a83a660fe2 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -44,38 +44,9 @@ plane .. code-block:: console $ curl -s http://localhost:19000/config_dump | jq '.configs[1].static_clusters' - [ - { - "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-24T18:30:55.458Z" - } - ] +.. literalinclude:: _include/dynamic-configuration/response-config-cluster.json + :language: json Step 5: Start the go-control-plane ********************************** From e785cc4eb38046d090973baa7748ab387fc802f1 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Sun, 25 Oct 2020 20:39:58 +0000 Subject: [PATCH 15/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration.rst | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index 62a83a660fe2..dab1739a61ae 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -23,9 +23,11 @@ First lets build our containers and start the proxy container, and two backend H $ docker-compose up -d proxy $ docker-compose ps - Name Command State Ports - ----------------------------------------------------------------------------------------------- - + 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 ************************** @@ -37,7 +39,6 @@ Nothing is listening on 10000 $ curl http://localhost:10000 curl: (56) Recv failure: Connection reset by peer - If we config dump the clusters we just see the ``xds_cluster`` we configured for the control plane @@ -56,9 +57,12 @@ Step 5: Start the go-control-plane $ docker-compose up -d go-control-plane $ docker-compose ps - Name Command State Ports - ----------------------------------------------------------------------------------------------- - + 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 *********************** From 7f23b706cafe9b276709b6969621b92778f57898 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 06:47:00 +0000 Subject: [PATCH 16/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration.rst | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index dab1739a61ae..58da8a4f5a4a 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -15,6 +15,8 @@ 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 @@ -32,14 +34,14 @@ First lets build our containers and start the proxy container, and two backend H Step 4: Check web response ************************** -Nothing is listening on 10000 +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 clusters we just see the ``xds_cluster`` we configured for the control +If we config dump the ``static_clusters`` we should see the ``xds_cluster`` we configured for the control plane .. code-block:: console @@ -52,6 +54,8 @@ plane 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 -d go-control-plane @@ -67,10 +71,36 @@ Step 5: Start the go-control-plane 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 ********************************* From 90f2b67a8c6b5b26ba8b12fab3b8fa0e75d4c185 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 06:59:11 +0000 Subject: [PATCH 17/46] docs/ Signed-off-by: Ryan Northey --- .../response-config-active-clusters.json | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters.json diff --git a/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters.json b/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters.json new file mode 100644 index 000000000000..f51d9df5e527 --- /dev/null +++ b/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters.json @@ -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" + } +] From 25c44b7e9364018ba9887505c3b8c11467e76d36 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 07:32:04 +0000 Subject: [PATCH 18/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration.rst | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index 58da8a4f5a4a..467180ea32a5 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -105,14 +105,56 @@ to ``service1`` Step 5: Stop the go-control-plane ********************************* +Let's stop the go-control-plane: -Step 5: Query the proxy -*********************** +.. 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``: + +.. literalinclude:: _include/dynamic-configuration/resource.go + :language: go + :lines: 33-40 + :emphasize-lines: 5 + :linenos: + +Further down in this file you must also change the configuration snapshot +version number: + +.. literalinclude:: _include/dynamic-configuration/resource.go + :language: go + :lines: 167-177 + :emphasize-lines: 2 + :linenos: Step 5: Query the proxy *********************** + +.. code-block:: console + + $ curl http://localhost:10000 + Request served by service2 + + 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 From e299084687e85974ac5e06f740a0262687692b74 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 07:59:09 +0000 Subject: [PATCH 19/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration.rst | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index 467180ea32a5..52b17edc1f3f 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -9,6 +9,8 @@ Dynamic configuration Step 3: Take a look at the proxy config *************************************** +.. literalinclude:: _include/dynamic-configuration/envoy.yaml + :language: yaml Step 4: Start the proxy container ********************************* @@ -42,7 +44,7 @@ Nothing is responding on port 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 +plane: .. code-block:: console @@ -54,11 +56,13 @@ plane 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" +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 -d go-control-plane + $ docker-compose up --build -d go-control-plane $ docker-compose ps Name Command State Ports @@ -97,7 +101,7 @@ to ``service1`` .. code-block:: console - curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' + $ curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' .. literalinclude:: _include/dynamic-configuration/response-config-active-clusters.json :language: json @@ -124,26 +128,37 @@ 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``: +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: 5 + :emphasize-lines: 6 :linenos: Further down in this file you must also change the configuration snapshot -version number: +version number from ``"1"`` to ``"2"``: .. literalinclude:: _include/dynamic-configuration/resource.go :language: go + :lineno-start: 167 :lines: 167-177 - :emphasize-lines: 2 + :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 From e2eccd17ad785a9c6ea7ac74d0b8b033aa75d3f7 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 07:59:11 +0000 Subject: [PATCH 20/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-configuration/verify.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-configuration/verify.sh index 5d9f51872167..0470a60f4b17 100755 --- a/examples/dynamic-configuration/verify.sh +++ b/examples/dynamic-configuration/verify.sh @@ -35,7 +35,7 @@ curl -s http://localhost:19000/config_dump \ run_log "Bring down the control plane" docker-compose stop go-control-plane -sleep 5 +sleep 2 run_log "Check for continued response from service1 backend" responds_with \ @@ -56,7 +56,7 @@ sed -i s/\"1\",/\"2\",/ resource.go run_log "Bring back up the control plane" docker-compose up --build -d go-control-plane -sleep 20 +wait_for 30 sh -c "docker-compose ps go-control-plane | grep healthy | grep -v unhealthy" run_log "Check for response from service2 backend" responds_with \ From c403196c5243d43993dc46b7cd53f536a57eca3b Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 08:44:42 +0000 Subject: [PATCH 21/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration.rst | 67 ++++++++++--------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index 52b17edc1f3f..b2a3a8c0cf1c 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -3,16 +3,15 @@ Dynamic configuration ===================== -.. include:: _include/docker-env-setup.rst - +This example walks through configuring Envoy using the `Go Control Plane ` +reference implementation. -Step 3: Take a look at the proxy config -*************************************** +It demonstrates how configuration provided to Envoy persists, even when the control plane is not available, +and a trivial example of how to update Envoy's configuration dynamically. -.. literalinclude:: _include/dynamic-configuration/envoy.yaml - :language: yaml +.. include:: _include/docker-env-setup.rst -Step 4: Start the proxy container +Step 3: Start the proxy container ********************************* First lets build our containers and start the proxy container, and two backend HTTP echo servers. @@ -33,17 +32,17 @@ The go-control-plane has not yet been started. 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 -************************** +Step 4: Check initial config and web response +********************************************* -Nothing is responding on port 10000 +As we have not yet started the control plane, nothing should be 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 +If you config dump the ``static_clusters`` you should see the ``xds_cluster`` configured for the control plane: .. code-block:: console @@ -53,10 +52,10 @@ plane: .. literalinclude:: _include/dynamic-configuration/response-config-cluster.json :language: json -Step 5: Start the go-control-plane -********************************** +Step 5: Start the control plane +******************************* -Let's start up the go-control-plane. +Let's start up the control plane. You may need to wait a moment or two for the service to become ``healthy``. @@ -72,10 +71,10 @@ You may need to wait a moment or two for the service to become ``healthy``. 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 +Step 6: Query the proxy *********************** -Once the control plane has started, we should be able to make a request to port ``10000``, which will be +Once the control plane has started, you should be able to make a request to port ``10000``, which will be served by ``service1``. .. code-block:: console @@ -93,11 +92,11 @@ served by ``service1``. Content-Length: 0 User-Agent: curl/7.72.0 -Step 5: Dump the proxy config again -*********************************** +Step 5: Dump Envoy's ``dynamic_active_clusters`` config +******************************************************* -If we now ``config_dump`` the ``dynamic_active_clusters`` we should see the endpoint pointing -to ``service1`` +If you now ``config_dump`` the ``dynamic_active_clusters`` you should see Envoy is configured +with the cluster endpoint pointing to ``service1`` .. code-block:: console @@ -106,10 +105,10 @@ to ``service1`` .. literalinclude:: _include/dynamic-configuration/response-config-active-clusters.json :language: json -Step 5: Stop the go-control-plane -********************************* +Step 6: Stop the control plane +****************************** -Let's stop the go-control-plane: +Stop the go-control-plane: .. code-block:: console @@ -122,10 +121,11 @@ The Envoy proxy should continue proxying responses from ``service1`` $ curl http://localhost:10000 | grep "served by" Request served by service1 -Step 5: Edit resource.go and restart the go-control-plane +Step 7: Edit resource.go and restart the go-control-plane ********************************************************* -The example go-control-plane is started with a custom resource.go file which +The example setup starts `go-control-plane `_ +with a custom :download:`resource.go <_include/dynamic-configuration/resource.go>` file which specifies the configuration provided to Envoy. If you edit this file and change the ``UpstreamHost`` from ``service1`` to ``service2``: @@ -136,8 +136,8 @@ If you edit this file and change the ``UpstreamHost`` from ``service1`` to ``ser :emphasize-lines: 6 :linenos: -Further down in this file you must also change the configuration snapshot -version number from ``"1"`` to ``"2"``: +Further down in this file you must also change the configuration snapshot version number from +``"1"`` to ``"2"`` to ensure Envoy sees the new configuration as newer: .. literalinclude:: _include/dynamic-configuration/resource.go :language: go @@ -146,18 +146,18 @@ version number from ``"1"`` to ``"2"``: :emphasize-lines: 3 :linenos: -Now rebuild and restart the go-control-plane: +Now rebuild and restart the 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``. +You may need to wait a moment or two for the ``go-control-plane`` service to become ``healthy``. -Step 5: Query the proxy -*********************** +Step 8: Check Envoy uses the updated configuration +************************************************** -When you make +Now when you make a request to the proxy it should be served by the ``service2`` backend. .. code-block:: console @@ -173,3 +173,6 @@ When you make X-Envoy-Expected-Rq-Timeout-Ms: 15000 Content-Length: 0 User-Agent: curl/7.72.0 + + +Add config dump... From 151b4c701386e55a7300d56b50a29109b9cab395 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 09:28:55 +0000 Subject: [PATCH 22/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration.rst | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index b2a3a8c0cf1c..b49e919a3b94 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -3,20 +3,24 @@ Dynamic configuration ===================== -This example walks through configuring Envoy using the `Go Control Plane ` +This example walks through configuring Envoy using the `Go Control Plane `_ reference implementation. It demonstrates how configuration provided to Envoy persists, even when the control plane is not available, -and a trivial example of how to update Envoy's configuration dynamically. +and provides a trivial example of how to update Envoy's configuration dynamically. .. include:: _include/docker-env-setup.rst +Change directory to ``examples/dynamic-configuration`` in the Envoy repository. + Step 3: Start the proxy container ********************************* -First lets build our containers and start the proxy container, and two backend HTTP echo servers. +First build the containers and start the ``proxy`` container. + +This should also start two backend ``HTTP`` echo servers, ``service1`` and ``service2``. -The go-control-plane has not yet been started. +The control plane has not yet been started. .. code-block:: console @@ -35,15 +39,15 @@ The go-control-plane has not yet been started. Step 4: Check initial config and web response ********************************************* -As we have not yet started the control plane, nothing should be responding on port 10000 +As we have not yet started the control plane, nothing should be responding on port ``10000``. .. code-block:: console $ curl http://localhost:10000 curl: (56) Recv failure: Connection reset by peer -If you config dump the ``static_clusters`` you should see the ``xds_cluster`` configured for the control -plane: +Dump the proxy's ``static_clusters`` configuration and you should see the ``xds_cluster`` +configured for the control plane: .. code-block:: console @@ -55,9 +59,9 @@ plane: Step 5: Start the control plane ******************************* -Let's start up the control plane. +Start up the ``go-control-plane`` service. -You may need to wait a moment or two for the service to become ``healthy``. +You may need to wait a moment or two for it to become ``healthy``. .. code-block:: console @@ -74,8 +78,8 @@ You may need to wait a moment or two for the service to become ``healthy``. Step 6: Query the proxy *********************** -Once the control plane has started, you should be able to make a request to port ``10000``, which will be -served by ``service1``. +Once the control plane has started and is ``healthy``, you should be able to make a request to port ``10000``, +which will be served by ``service1``. .. code-block:: console @@ -95,8 +99,8 @@ served by ``service1``. Step 5: Dump Envoy's ``dynamic_active_clusters`` config ******************************************************* -If you now ``config_dump`` the ``dynamic_active_clusters`` you should see Envoy is configured -with the cluster endpoint pointing to ``service1`` +If you now dump the proxy's ``dynamic_active_clusters`` configuration, you should see it is configured +with the cluster pointing to ``service1`` .. code-block:: console @@ -114,7 +118,7 @@ Stop the go-control-plane: $ docker-compose stop go-control-plane -The Envoy proxy should continue proxying responses from ``service1`` +The Envoy proxy should continue proxying responses from ``service1``. .. code-block:: console @@ -128,7 +132,10 @@ The example setup starts `go-control-plane ` file which specifies the configuration provided to Envoy. -If you edit this file and change the ``UpstreamHost`` from ``service1`` to ``service2``: +Let's update this to have Envoy proxy instead to ``service2``. + +Edit ``resource.go`` in the dynamic configuration example folder and change the ``UpstreamHost`` +from ``service1`` to ``service2``: .. literalinclude:: _include/dynamic-configuration/resource.go :language: go @@ -137,7 +144,7 @@ If you edit this file and change the ``UpstreamHost`` from ``service1`` to ``ser :linenos: Further down in this file you must also change the configuration snapshot version number from -``"1"`` to ``"2"`` to ensure Envoy sees the new configuration as newer: +``"1"`` to ``"2"`` to ensure Envoy sees the configuration as newer: .. literalinclude:: _include/dynamic-configuration/resource.go :language: go @@ -174,5 +181,12 @@ Now when you make a request to the proxy it should be served by the ``service2`` Content-Length: 0 User-Agent: curl/7.72.0 +Dumping the ``dynamic_active_clusters`` you should see the cluster is now configured with +``service2``: + +.. code-block:: console -Add config dump... + $ curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' + +.. literalinclude:: _include/dynamic-configuration/response-config-active-clusters.json + :language: json From c487ca919390d65b267bab994be972a0e1af1a4e Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 14:40:46 +0000 Subject: [PATCH 23/46] docs/ Signed-off-by: Ryan Northey --- docs/root/start/sandboxes/dynamic-configuration.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration.rst index b49e919a3b94..b99a601ac12e 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration.rst @@ -56,6 +56,13 @@ configured for the control plane: .. literalinclude:: _include/dynamic-configuration/response-config-cluster.json :language: json +No ``dynamic_active_clusters`` have been configured yet: + +.. code-block:: console + + $ curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' + null + Step 5: Start the control plane ******************************* @@ -112,7 +119,7 @@ with the cluster pointing to ``service1`` Step 6: Stop the control plane ****************************** -Stop the go-control-plane: +Stop the ``go-control-plane`` service: .. code-block:: console @@ -188,5 +195,5 @@ Dumping the ``dynamic_active_clusters`` you should see the cluster is now config $ curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' -.. literalinclude:: _include/dynamic-configuration/response-config-active-clusters.json +.. literalinclude:: _include/dynamic-configuration/response-config-active-clusters-updated.json :language: json From 42985e7df5186503460786e63b81ca8bd7110219 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 14:40:49 +0000 Subject: [PATCH 24/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-configuration/envoy.yaml | 7 ------- examples/dynamic-configuration/resource.go | 4 ++-- examples/dynamic-configuration/verify.sh | 5 +++++ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/dynamic-configuration/envoy.yaml b/examples/dynamic-configuration/envoy.yaml index f43e9ded7d12..9c0e7f2865d0 100644 --- a/examples/dynamic-configuration/envoy.yaml +++ b/examples/dynamic-configuration/envoy.yaml @@ -12,7 +12,6 @@ dynamic_resources: grpc_services: - envoy_grpc: cluster_name: xds_cluster - set_node_on_first_message_only: false cds_config: resource_api_version: V3 ads: {} @@ -45,9 +44,3 @@ layered_runtime: resource_api_version: V3 ads: {} name: runtime-0 - - name: runtime-1 - rtds_layer: - rtds_config: - resource_api_version: V3 - ads: {} - name: runtime-1 diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-configuration/resource.go index ca0daf78a84a..e6f54c94c381 100644 --- a/examples/dynamic-configuration/resource.go +++ b/examples/dynamic-configuration/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service1" + UpstreamHost = "service2" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "1", + "2", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-configuration/verify.sh index 0470a60f4b17..e5666be168d2 100755 --- a/examples/dynamic-configuration/verify.sh +++ b/examples/dynamic-configuration/verify.sh @@ -9,6 +9,11 @@ export UPARGS=" proxy" run_log "Check port 10000 is not open (still shows as succeeded)" nc -zv localhost 10000 |& grep -v open +run_log "Check the static cluster" +curl -s http://localhost:19000/config_dump \ + | jq -r '.configs[1].static_clusters' \ + | grep 'go-control-plane' + run_log "Check there is no config for dynamic clusters" curl -s http://localhost:19000/config_dump \ | jq -r '.configs[1].dynamic_active_clusters // "NO_CLUSTERS"' \ From c1ae8d2c70f5d28c88979bfe47b7173d2e3ca61d Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 14:43:45 +0000 Subject: [PATCH 25/46] resource.go Signed-off-by: Ryan Northey --- examples/dynamic-configuration/resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-configuration/resource.go index e6f54c94c381..ca0daf78a84a 100644 --- a/examples/dynamic-configuration/resource.go +++ b/examples/dynamic-configuration/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service2" + UpstreamHost = "service1" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "2", + "1", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, From 983ea43caef80c1168dbdb0b81ed9917b8c44170 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 14:52:40 +0000 Subject: [PATCH 26/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-configuration/envoy.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/dynamic-configuration/envoy.yaml b/examples/dynamic-configuration/envoy.yaml index 9c0e7f2865d0..8102dd7199b5 100644 --- a/examples/dynamic-configuration/envoy.yaml +++ b/examples/dynamic-configuration/envoy.yaml @@ -1,9 +1,6 @@ -admin: - access_log_path: /dev/null - address: - socket_address: - address: 0.0.0.0 - port_value: 19000 +node: + cluster: test-cluster + id: test-id dynamic_resources: ads_config: @@ -18,9 +15,7 @@ dynamic_resources: lds_config: resource_api_version: V3 ads: {} -node: - cluster: test-cluster - id: test-id + static_resources: clusters: - connect_timeout: 1s @@ -44,3 +39,10 @@ layered_runtime: resource_api_version: V3 ads: {} name: runtime-0 + +admin: + access_log_path: /dev/null + address: + socket_address: + address: 0.0.0.0 + port_value: 19000 From cfbae814d51a6aeb2c31ba00e9db14ab5005693d Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 14:57:53 +0000 Subject: [PATCH 27/46] examples Signed-off-by: Ryan Northey --- examples/dynamic-configuration/envoy.yaml | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/dynamic-configuration/envoy.yaml b/examples/dynamic-configuration/envoy.yaml index 8102dd7199b5..528ccbfdd2d0 100644 --- a/examples/dynamic-configuration/envoy.yaml +++ b/examples/dynamic-configuration/envoy.yaml @@ -7,8 +7,8 @@ dynamic_resources: api_type: GRPC transport_api_version: V3 grpc_services: - - envoy_grpc: - cluster_name: xds_cluster + - envoy_grpc: + cluster_name: xds_cluster cds_config: resource_api_version: V3 ads: {} @@ -18,17 +18,17 @@ dynamic_resources: 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 + - 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: From 6d6d06679cb80d7c794e208ceaeb297a50f0f791 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 15:00:37 +0000 Subject: [PATCH 28/46] docs/ Signed-off-by: Ryan Northey --- ...sponse-config-active-clusters-updated.json | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters-updated.json diff --git a/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters-updated.json b/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters-updated.json new file mode 100644 index 000000000000..4ff0f03a2c1a --- /dev/null +++ b/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters-updated.json @@ -0,0 +1,32 @@ +[ + { + "version_info": "2", + "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": "service2", + "port_value": 8080 + } + } + } + } + ] + } + ] + } + }, + "last_updated": "2020-10-26T14:35:17.360Z" + } +] From 8b09bcef0517946b38545115e4cb9ea4dd9738e8 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 26 Oct 2020 15:15:49 +0000 Subject: [PATCH 29/46] envoy.yaml Signed-off-by: Ryan Northey --- examples/dynamic-configuration/envoy.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/dynamic-configuration/envoy.yaml b/examples/dynamic-configuration/envoy.yaml index 528ccbfdd2d0..350cf1ed1eec 100644 --- a/examples/dynamic-configuration/envoy.yaml +++ b/examples/dynamic-configuration/envoy.yaml @@ -20,6 +20,8 @@ static_resources: clusters: - connect_timeout: 1s type: strict_dns + http2_protocol_options: {} + name: xds_cluster load_assignment: cluster_name: xds_cluster endpoints: @@ -29,8 +31,7 @@ static_resources: socket_address: address: go-control-plane port_value: 18000 - http2_protocol_options: {} - name: xds_cluster + layered_runtime: layers: - name: runtime-0 From 63048d4a11bf609751c15b2cc804a11bfa804d3a Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 18:14:41 +0000 Subject: [PATCH 30/46] rename dynamic-configuration -> dynamic-config-cp Signed-off-by: Ryan Northey --- ...> dynamic-configuration-control-plane.rst} | 30 +++++++++---------- .../Dockerfile-control-plane | 0 .../Dockerfile-proxy | 0 .../README.md | 0 .../docker-compose.yaml | 0 .../envoy.yaml | 0 .../resource.go | 0 .../verify.sh | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) rename docs/root/start/sandboxes/{dynamic-configuration.rst => dynamic-configuration-control-plane.rst} (80%) rename examples/{dynamic-configuration => dynamic-config-cp}/Dockerfile-control-plane (100%) rename examples/{dynamic-configuration => dynamic-config-cp}/Dockerfile-proxy (100%) rename examples/{dynamic-configuration => dynamic-config-cp}/README.md (100%) rename examples/{dynamic-configuration => dynamic-config-cp}/docker-compose.yaml (100%) rename examples/{dynamic-configuration => dynamic-config-cp}/envoy.yaml (100%) rename examples/{dynamic-configuration => dynamic-config-cp}/resource.go (100%) rename examples/{dynamic-configuration => dynamic-config-cp}/verify.sh (98%) diff --git a/docs/root/start/sandboxes/dynamic-configuration.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst similarity index 80% rename from docs/root/start/sandboxes/dynamic-configuration.rst rename to docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index b99a601ac12e..8ed1bd387be0 100644 --- a/docs/root/start/sandboxes/dynamic-configuration.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -11,7 +11,7 @@ and provides a trivial example of how to update Envoy's configuration dynamicall .. include:: _include/docker-env-setup.rst -Change directory to ``examples/dynamic-configuration`` in the Envoy repository. +Change directory to ``examples/dynamic-config-cp`` in the Envoy repository. Step 3: Start the proxy container ********************************* @@ -25,16 +25,16 @@ The control plane has not yet been started. .. code-block:: console $ pwd - envoy/examples/dynamic-configuration + envoy/examples/dynamic-config-cp $ 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 + dynamic-config-cp_proxy_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp, 0.0.0.0:19000->19000/tcp + dynamic-config-cp_service1_1 /bin/echo-server Up 8080/tcp + dynamic-config-cp_service2_1 /bin/echo-server Up 8080/tcp Step 4: Check initial config and web response ********************************************* @@ -53,7 +53,7 @@ configured for the control plane: $ curl -s http://localhost:19000/config_dump | jq '.configs[1].static_clusters' -.. literalinclude:: _include/dynamic-configuration/response-config-cluster.json +.. literalinclude:: _include/dynamic-config-cp/response-config-cluster.json :language: json No ``dynamic_active_clusters`` have been configured yet: @@ -77,10 +77,10 @@ You may need to wait a moment or two for it to become ``healthy``. 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 + dynamic-config-cp_go-control-plane_1 bin/example -debug Up (healthy) + dynamic-config-cp_proxy_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp, 0.0.0.0:19000->19000/tcp + dynamic-config-cp_service1_1 /bin/echo-server Up 8080/tcp + dynamic-config-cp_service2_1 /bin/echo-server Up 8080/tcp Step 6: Query the proxy *********************** @@ -113,7 +113,7 @@ with the cluster pointing to ``service1`` $ curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' -.. literalinclude:: _include/dynamic-configuration/response-config-active-clusters.json +.. literalinclude:: _include/dynamic-config-cp/response-config-active-clusters.json :language: json Step 6: Stop the control plane @@ -136,7 +136,7 @@ Step 7: Edit resource.go and restart the go-control-plane ********************************************************* The example setup starts `go-control-plane `_ -with a custom :download:`resource.go <_include/dynamic-configuration/resource.go>` file which +with a custom :download:`resource.go <_include/dynamic-config-cp/resource.go>` file which specifies the configuration provided to Envoy. Let's update this to have Envoy proxy instead to ``service2``. @@ -144,7 +144,7 @@ Let's update this to have Envoy proxy instead to ``service2``. Edit ``resource.go`` in the dynamic configuration example folder and change the ``UpstreamHost`` from ``service1`` to ``service2``: -.. literalinclude:: _include/dynamic-configuration/resource.go +.. literalinclude:: _include/dynamic-config-cp/resource.go :language: go :lines: 33-40 :emphasize-lines: 6 @@ -153,7 +153,7 @@ from ``service1`` to ``service2``: Further down in this file you must also change the configuration snapshot version number from ``"1"`` to ``"2"`` to ensure Envoy sees the configuration as newer: -.. literalinclude:: _include/dynamic-configuration/resource.go +.. literalinclude:: _include/dynamic-config-cp/resource.go :language: go :lineno-start: 167 :lines: 167-177 @@ -195,5 +195,5 @@ Dumping the ``dynamic_active_clusters`` you should see the cluster is now config $ curl -s http://localhost:19000/config_dump | jq '.configs[1].dynamic_active_clusters' -.. literalinclude:: _include/dynamic-configuration/response-config-active-clusters-updated.json +.. literalinclude:: _include/dynamic-config-cp/response-config-active-clusters-updated.json :language: json diff --git a/examples/dynamic-configuration/Dockerfile-control-plane b/examples/dynamic-config-cp/Dockerfile-control-plane similarity index 100% rename from examples/dynamic-configuration/Dockerfile-control-plane rename to examples/dynamic-config-cp/Dockerfile-control-plane diff --git a/examples/dynamic-configuration/Dockerfile-proxy b/examples/dynamic-config-cp/Dockerfile-proxy similarity index 100% rename from examples/dynamic-configuration/Dockerfile-proxy rename to examples/dynamic-config-cp/Dockerfile-proxy diff --git a/examples/dynamic-configuration/README.md b/examples/dynamic-config-cp/README.md similarity index 100% rename from examples/dynamic-configuration/README.md rename to examples/dynamic-config-cp/README.md diff --git a/examples/dynamic-configuration/docker-compose.yaml b/examples/dynamic-config-cp/docker-compose.yaml similarity index 100% rename from examples/dynamic-configuration/docker-compose.yaml rename to examples/dynamic-config-cp/docker-compose.yaml diff --git a/examples/dynamic-configuration/envoy.yaml b/examples/dynamic-config-cp/envoy.yaml similarity index 100% rename from examples/dynamic-configuration/envoy.yaml rename to examples/dynamic-config-cp/envoy.yaml diff --git a/examples/dynamic-configuration/resource.go b/examples/dynamic-config-cp/resource.go similarity index 100% rename from examples/dynamic-configuration/resource.go rename to examples/dynamic-config-cp/resource.go diff --git a/examples/dynamic-configuration/verify.sh b/examples/dynamic-config-cp/verify.sh similarity index 98% rename from examples/dynamic-configuration/verify.sh rename to examples/dynamic-config-cp/verify.sh index e5666be168d2..0cc02650a8dc 100755 --- a/examples/dynamic-configuration/verify.sh +++ b/examples/dynamic-config-cp/verify.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -export NAME=dynamic-configuration +export NAME=dynamic-config-cp export UPARGS=" proxy" # shellcheck source=examples/verify-common.sh From a1da6176732ac32d52f87cdff9d1752d0eda5155 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 18:17:29 +0000 Subject: [PATCH 31/46] docs/ Signed-off-by: Ryan Northey --- .../dynamic-configuration-control-plane.rst | 14 +++++++------- docs/root/start/sandboxes/index.rst | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 8ed1bd387be0..660becc4af55 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -1,7 +1,7 @@ -.. _install_sandboxes_dynamic_configuration: +.. _install_sandboxes_dynamic_config_cp: -Dynamic configuration -===================== +Dynamic configuration using a control plane +=========================================== This example walks through configuring Envoy using the `Go Control Plane `_ reference implementation. @@ -30,8 +30,8 @@ The control plane has not yet been started. $ docker-compose up -d proxy $ docker-compose ps - Name Command State Ports - ------------------------------------------------------------------------------------------------------------------------------ + Name Command State Ports + ------------------------------------------------------------------------------------------------------------------------ dynamic-config-cp_proxy_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp, 0.0.0.0:19000->19000/tcp dynamic-config-cp_service1_1 /bin/echo-server Up 8080/tcp dynamic-config-cp_service2_1 /bin/echo-server Up 8080/tcp @@ -75,8 +75,8 @@ You may need to wait a moment or two for it to become ``healthy``. $ docker-compose up --build -d go-control-plane $ docker-compose ps - Name Command State Ports - ----------------------------------------------------------------------------------------------------------------------------------------- + Name Command State Ports + ------------------------------------------------------------------------------------------------------------------------------------- dynamic-config-cp_go-control-plane_1 bin/example -debug Up (healthy) dynamic-config-cp_proxy_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp, 0.0.0.0:19000->19000/tcp dynamic-config-cp_service1_1 /bin/echo-server Up 8080/tcp diff --git a/docs/root/start/sandboxes/index.rst b/docs/root/start/sandboxes/index.rst index 8f9c4a5eb1d7..550776cd2503 100644 --- a/docs/root/start/sandboxes/index.rst +++ b/docs/root/start/sandboxes/index.rst @@ -14,7 +14,7 @@ features. The following sandboxes are available: cache cors csrf - dynamic-configuration + dynamic-configuration-control-plane ext_authz fault_injection front_proxy From 8cf7656ce24a4d18a179cf1889733fa9aa678b16 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 18:46:37 +0000 Subject: [PATCH 32/46] docs/ Signed-off-by: Ryan Northey --- .../response-config-active-clusters-updated.json | 0 .../response-config-active-clusters.json | 0 .../response-config-cluster.json | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename docs/root/start/sandboxes/_include/{dynamic-configuration => dynamic-config-cp}/response-config-active-clusters-updated.json (100%) rename docs/root/start/sandboxes/_include/{dynamic-configuration => dynamic-config-cp}/response-config-active-clusters.json (100%) rename docs/root/start/sandboxes/_include/{dynamic-configuration => dynamic-config-cp}/response-config-cluster.json (100%) diff --git a/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters-updated.json b/docs/root/start/sandboxes/_include/dynamic-config-cp/response-config-active-clusters-updated.json similarity index 100% rename from docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters-updated.json rename to docs/root/start/sandboxes/_include/dynamic-config-cp/response-config-active-clusters-updated.json diff --git a/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters.json b/docs/root/start/sandboxes/_include/dynamic-config-cp/response-config-active-clusters.json similarity index 100% rename from docs/root/start/sandboxes/_include/dynamic-configuration/response-config-active-clusters.json rename to docs/root/start/sandboxes/_include/dynamic-config-cp/response-config-active-clusters.json diff --git a/docs/root/start/sandboxes/_include/dynamic-configuration/response-config-cluster.json b/docs/root/start/sandboxes/_include/dynamic-config-cp/response-config-cluster.json similarity index 100% rename from docs/root/start/sandboxes/_include/dynamic-configuration/response-config-cluster.json rename to docs/root/start/sandboxes/_include/dynamic-config-cp/response-config-cluster.json From bd316899d30258616da3dfbde0951ef1c132e7bf Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 19:55:00 +0000 Subject: [PATCH 33/46] docs/ Signed-off-by: Ryan Northey --- .../dynamic-configuration-control-plane.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 660becc4af55..2db250a75235 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -18,7 +18,7 @@ Step 3: Start the proxy container First build the containers and start the ``proxy`` container. -This should also start two backend ``HTTP`` echo servers, ``service1`` and ``service2``. +This should also start two upstream ``HTTP`` echo servers, ``service1`` and ``service2``. The control plane has not yet been started. @@ -46,7 +46,7 @@ As we have not yet started the control plane, nothing should be responding on po $ curl http://localhost:10000 curl: (56) Recv failure: Connection reset by peer -Dump the proxy's ``static_clusters`` configuration and you should see the ``xds_cluster`` +Dump the proxy's ``static_clusters`` configuration and you should see the cluster named ``xds_cluster`` configured for the control plane: .. code-block:: console @@ -55,6 +55,7 @@ configured for the control plane: .. literalinclude:: _include/dynamic-config-cp/response-config-cluster.json :language: json + :emphasize-lines: 10, 18-19 No ``dynamic_active_clusters`` have been configured yet: @@ -107,7 +108,7 @@ Step 5: Dump Envoy's ``dynamic_active_clusters`` config ******************************************************* If you now dump the proxy's ``dynamic_active_clusters`` configuration, you should see it is configured -with the cluster pointing to ``service1`` +with the ``example_proxy-cluster`` pointing to ``service1`` .. code-block:: console @@ -115,6 +116,7 @@ with the cluster pointing to ``service1`` .. literalinclude:: _include/dynamic-config-cp/response-config-active-clusters.json :language: json + :emphasize-lines: 11, 19-20 Step 6: Stop the control plane ****************************** @@ -139,7 +141,7 @@ The example setup starts `go-control-plane ` file which specifies the configuration provided to Envoy. -Let's update this to have Envoy proxy instead to ``service2``. +Update this to have Envoy proxy instead to ``service2``. Edit ``resource.go`` in the dynamic configuration example folder and change the ``UpstreamHost`` from ``service1`` to ``service2``: @@ -166,12 +168,12 @@ Now rebuild and restart the control plane: $ docker-compose up --build -d go-control-plane -You may need to wait a moment or two for the ``go-control-plane`` service to become ``healthy``. +You may need to wait a moment or two for the ``go-control-plane`` service to become ``healthy`` again. Step 8: Check Envoy uses the updated configuration ************************************************** -Now when you make a request to the proxy it should be served by the ``service2`` backend. +Now when you make a request to the proxy it should be served by the ``service2`` upstream service. .. code-block:: console @@ -197,3 +199,4 @@ Dumping the ``dynamic_active_clusters`` you should see the cluster is now config .. literalinclude:: _include/dynamic-config-cp/response-config-active-clusters-updated.json :language: json + :emphasize-lines: 11, 19-20 From 78ea83fc76045242e19429b2940d2dc81f9012fe Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 19:55:04 +0000 Subject: [PATCH 34/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-config-cp/README.md | 2 +- examples/dynamic-config-cp/resource.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/dynamic-config-cp/README.md b/examples/dynamic-config-cp/README.md index 346b020e98c8..936e6dd00f7a 100644 --- a/examples/dynamic-config-cp/README.md +++ b/examples/dynamic-config-cp/README.md @@ -1,2 +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). +to the [Envoy docs](https://www.envoyproxy.io/docs/envoy/latest/start/sandboxes/dynamic-configuration-control-plane.html). diff --git a/examples/dynamic-config-cp/resource.go b/examples/dynamic-config-cp/resource.go index ca0daf78a84a..e6f54c94c381 100644 --- a/examples/dynamic-config-cp/resource.go +++ b/examples/dynamic-config-cp/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service1" + UpstreamHost = "service2" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "1", + "2", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, From cff56c2686657f3c91c65b979cbe3340a0ee69aa Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 20:01:19 +0000 Subject: [PATCH 35/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-config-cp/resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/dynamic-config-cp/resource.go b/examples/dynamic-config-cp/resource.go index e6f54c94c381..ca0daf78a84a 100644 --- a/examples/dynamic-config-cp/resource.go +++ b/examples/dynamic-config-cp/resource.go @@ -35,7 +35,7 @@ const ( RouteName = "local_route" ListenerName = "listener_0" ListenerPort = 10000 - UpstreamHost = "service2" + UpstreamHost = "service1" UpstreamPort = 8080 ) @@ -166,7 +166,7 @@ func makeConfigSource() *core.ConfigSource { func GenerateSnapshot() cache.Snapshot { return cache.NewSnapshot( - "2", + "1", []types.Resource{}, // endpoints []types.Resource{makeCluster(ClusterName)}, []types.Resource{makeRoute(RouteName, ClusterName)}, From 1c212694df1a05dfbd9f5896468da998326997c8 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 20:02:16 +0000 Subject: [PATCH 36/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration-control-plane.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 2db250a75235..8e41fb4bded2 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -108,7 +108,7 @@ Step 5: Dump Envoy's ``dynamic_active_clusters`` config ******************************************************* If you now dump the proxy's ``dynamic_active_clusters`` configuration, you should see it is configured -with the ``example_proxy-cluster`` pointing to ``service1`` +with the ``example_proxy_cluster`` pointing to ``service1`` .. code-block:: console From 2d3795eac43c5cfa3808ce38d387a7c4bb85f84e Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 20:26:47 +0000 Subject: [PATCH 37/46] docs/ Signed-off-by: Ryan Northey --- .../root/start/sandboxes/dynamic-configuration-control-plane.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 8e41fb4bded2..ac1b098a52b3 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -149,6 +149,7 @@ from ``service1`` to ``service2``: .. literalinclude:: _include/dynamic-config-cp/resource.go :language: go :lines: 33-40 + :lineno-start: 33 :emphasize-lines: 6 :linenos: From 4661f9215c7b0bf437b6ac8f4e7c61c6e829e609 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 20:36:51 +0000 Subject: [PATCH 38/46] docs/ Signed-off-by: Ryan Northey --- .../sandboxes/dynamic-configuration-control-plane.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index ac1b098a52b3..a41da4eed70c 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -108,7 +108,7 @@ Step 5: Dump Envoy's ``dynamic_active_clusters`` config ******************************************************* If you now dump the proxy's ``dynamic_active_clusters`` configuration, you should see it is configured -with the ``example_proxy_cluster`` pointing to ``service1`` +with the ``example_proxy_cluster`` pointing to ``service1``, and a version of ``1``. .. code-block:: console @@ -116,7 +116,7 @@ with the ``example_proxy_cluster`` pointing to ``service1`` .. literalinclude:: _include/dynamic-config-cp/response-config-active-clusters.json :language: json - :emphasize-lines: 11, 19-20 + :emphasize-lines: 3, 11, 19-20 Step 6: Stop the control plane ****************************** @@ -192,7 +192,7 @@ Now when you make a request to the proxy it should be served by the ``service2`` User-Agent: curl/7.72.0 Dumping the ``dynamic_active_clusters`` you should see the cluster is now configured with -``service2``: +``service2``, and has a version of ``2``: .. code-block:: console @@ -200,4 +200,4 @@ Dumping the ``dynamic_active_clusters`` you should see the cluster is now config .. literalinclude:: _include/dynamic-config-cp/response-config-active-clusters-updated.json :language: json - :emphasize-lines: 11, 19-20 + :emphasize-lines: 3, 11, 19-20 From 61e289e585453d72fe8258798ff6bb6e35ccd898 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 20:37:55 +0000 Subject: [PATCH 39/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration-control-plane.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index a41da4eed70c..7f2f83ec05dc 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -1,7 +1,7 @@ .. _install_sandboxes_dynamic_config_cp: -Dynamic configuration using a control plane -=========================================== +Dynamic configuration (control plane) +===================================== This example walks through configuring Envoy using the `Go Control Plane `_ reference implementation. From 3fb94c1752c8667ef096fa9635e860089bfbc48d Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 20:55:27 +0000 Subject: [PATCH 40/46] examples/ Signed-off-by: Ryan Northey --- examples/dynamic-config-cp/envoy.yaml | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/dynamic-config-cp/envoy.yaml b/examples/dynamic-config-cp/envoy.yaml index 350cf1ed1eec..7d44f9ae6395 100644 --- a/examples/dynamic-config-cp/envoy.yaml +++ b/examples/dynamic-config-cp/envoy.yaml @@ -7,8 +7,8 @@ dynamic_resources: api_type: GRPC transport_api_version: V3 grpc_services: - - envoy_grpc: - cluster_name: xds_cluster + - envoy_grpc: + cluster_name: xds_cluster cds_config: resource_api_version: V3 ads: {} @@ -18,28 +18,28 @@ dynamic_resources: static_resources: clusters: - - connect_timeout: 1s - type: strict_dns - http2_protocol_options: {} - name: xds_cluster - load_assignment: - cluster_name: xds_cluster - endpoints: - - lb_endpoints: - - endpoint: - address: - socket_address: - address: go-control-plane - port_value: 18000 + - connect_timeout: 1s + type: strict_dns + http2_protocol_options: {} + name: xds_cluster + load_assignment: + cluster_name: xds_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: go-control-plane + port_value: 18000 layered_runtime: layers: - - name: runtime-0 - rtds_layer: - rtds_config: - resource_api_version: V3 - ads: {} - name: runtime-0 + - name: runtime-0 + rtds_layer: + name: runtime-0 + rtds_config: + resource_api_version: V3 + ads: {} admin: access_log_path: /dev/null From eefc0ad1dfbe4330471e5ebc0e15ef475397e951 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 20:58:44 +0000 Subject: [PATCH 41/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration-control-plane.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 7f2f83ec05dc..37f40e4f68fe 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -191,8 +191,8 @@ Now when you make a request to the proxy it should be served by the ``service2`` Content-Length: 0 User-Agent: curl/7.72.0 -Dumping the ``dynamic_active_clusters`` you should see the cluster is now configured with -``service2``, and has a version of ``2``: +Dumping the ``dynamic_active_clusters`` you should see the cluster configuration now has a version +of ``2`` is configured to proxy to ``service2``: .. code-block:: console From cf714f0ddc4c722647f42d994b1ced55e501decb Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 21:17:28 +0000 Subject: [PATCH 42/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration-control-plane.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 37f40e4f68fe..db16e0b3f063 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -192,7 +192,7 @@ Now when you make a request to the proxy it should be served by the ``service2`` User-Agent: curl/7.72.0 Dumping the ``dynamic_active_clusters`` you should see the cluster configuration now has a version -of ``2`` is configured to proxy to ``service2``: +of ``2``, and ``example_proxy_cluster`` is configured to proxy to ``service2``: .. code-block:: console From e0cab031ca9847df78046cd4e07869cb08ac7c13 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 21:50:20 +0000 Subject: [PATCH 43/46] docs/ Signed-off-by: Ryan Northey --- .../dynamic-configuration-control-plane.rst | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index db16e0b3f063..83976cb1b350 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -178,19 +178,9 @@ Now when you make a request to the proxy it should be served by the ``service2`` .. code-block:: console - $ curl http://localhost:10000 + $ curl http://localhost:10000 | grep "served by" Request served by service2 - 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 - Dumping the ``dynamic_active_clusters`` you should see the cluster configuration now has a version of ``2``, and ``example_proxy_cluster`` is configured to proxy to ``service2``: From 3d582e8b6dd65e99b17bb0adc8463187ab7b0838 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 23:03:18 +0000 Subject: [PATCH 44/46] remove host rewrite Signed-off-by: Ryan Northey --- examples/dynamic-config-cp/resource.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/dynamic-config-cp/resource.go b/examples/dynamic-config-cp/resource.go index ca0daf78a84a..2cc38f35bc20 100644 --- a/examples/dynamic-config-cp/resource.go +++ b/examples/dynamic-config-cp/resource.go @@ -92,9 +92,6 @@ func makeRoute(routeName string, clusterName string) *route.RouteConfiguration { ClusterSpecifier: &route.RouteAction_Cluster{ Cluster: clusterName, }, - HostRewriteSpecifier: &route.RouteAction_HostRewriteLiteral{ - HostRewriteLiteral: UpstreamHost, - }, }, }, }}, From 5f9d7325aeec9ede00e5a6c0677f8cfcd6bfb4c8 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 23:04:57 +0000 Subject: [PATCH 45/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration-control-plane.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 83976cb1b350..3ca5ab932dd4 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -158,8 +158,8 @@ Further down in this file you must also change the configuration snapshot versio .. literalinclude:: _include/dynamic-config-cp/resource.go :language: go - :lineno-start: 167 - :lines: 167-177 + :lineno-start: 164 + :lines: 164-174 :emphasize-lines: 3 :linenos: From 328c40fbcc2feb6f4c0f4a1e598da8cf8e10ba9b Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Tue, 27 Oct 2020 23:10:24 +0000 Subject: [PATCH 46/46] docs/ Signed-off-by: Ryan Northey --- .../start/sandboxes/dynamic-configuration-control-plane.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst index 3ca5ab932dd4..6874a9c3158c 100644 --- a/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst +++ b/docs/root/start/sandboxes/dynamic-configuration-control-plane.rst @@ -96,7 +96,7 @@ which will be served by ``service1``. HTTP/1.1 GET / - Host: service1 + Host: localhost:10000 Accept: */* X-Forwarded-Proto: http X-Request-Id: 1d93050e-f39c-4602-90f8-a124d6e78d26