{"id":15681316,"url":"https://github.com/int128/hello-envoy","last_synced_at":"2025-05-07T12:11:57.699Z","repository":{"id":40445366,"uuid":"376753974","full_name":"int128/hello-envoy","owner":"int128","description":"Example of Envoy TCP Proxy with dynamic filesystem configuration","archived":false,"fork":false,"pushed_at":"2022-05-08T12:25:39.000Z","size":23,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T12:11:51.169Z","etag":null,"topics":["docker","envoy","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/int128.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-14T08:26:03.000Z","updated_at":"2024-11-21T13:28:35.000Z","dependencies_parsed_at":"2022-08-09T20:40:19.370Z","dependency_job_id":null,"html_url":"https://github.com/int128/hello-envoy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fhello-envoy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fhello-envoy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fhello-envoy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int128%2Fhello-envoy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/int128","download_url":"https://codeload.github.com/int128/hello-envoy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873898,"owners_count":21817715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","envoy","kubernetes"],"created_at":"2024-10-03T16:52:33.557Z","updated_at":"2025-05-07T12:11:57.684Z","avatar_url":"https://github.com/int128.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hello-envoy [![envoy](https://github.com/int128/hello-envoy/actions/workflows/envoy.yaml/badge.svg)](https://github.com/int128/hello-envoy/actions/workflows/envoy.yaml)\n\nThis is an example of Envoy TCP Proxy with the dynamic configuration.\nIt is based on https://gist.github.com/int128/5b02bd1f9b7882aa6b48727b838e658e.\n\n## :book: Table of Contents\n\n- Static configuration (Docker)\n- Dynamic configuration (Docker)\n- Dynamic configuration (Kubernetes)\n\n## Static configuration\n\nTo run a proxy:\n\n```console\n% docker run --rm envoyproxy/envoy:v1.22-latest --version\n\nenvoy  version: dcd329a2e95b54f754b17aceca3f72724294b502/1.22.0/Clean/RELEASE/BoringSSL\n\n% docker run --rm -p 10000:10000 -v $PWD/envoy_static.yaml:/envoy_static.yaml:ro envoyproxy/envoy:v1.22-latest -c /envoy_static.yaml\n...\n[2022-04-24 07:13:37.518][1][info][config] [source/server/listener_manager_impl.cc:789] all dependencies initialized. starting workers\n```\n\nTo connect to the remote host via the proxy:\n\n```console\n% curl -v http://localhost:10000/get\n*   Trying 127.0.0.1:10000...\n* Connected to localhost (127.0.0.1) port 10000 (#0)\n\u003e GET /get HTTP/1.1\n\u003e Host: localhost:10000\n\u003e User-Agent: curl/7.79.1\n\u003e Accept: */*\n\u003e\n* Mark bundle as not supporting multiuse\n\u003c HTTP/1.1 200 OK\n\u003c Date: Sun, 24 Apr 2022 07:15:25 GMT\n\u003c Content-Type: application/json\n\u003c Content-Length: 250\n\u003c Connection: keep-alive\n\u003c Server: gunicorn/19.9.0\n\u003c Access-Control-Allow-Origin: *\n\u003c Access-Control-Allow-Credentials: true\n\u003c\n{\n  \"args\": {},\n  \"headers\": {\n    \"Accept\": \"*/*\",\n    \"Host\": \"localhost\",\n    \"User-Agent\": \"curl/7.79.1\",\n    \"X-Amzn-Trace-Id\": \"Root=1-6264f90d-79e432f97032afa8435446e0\"\n  },\n  \"origin\": \"192.168.0.0\",\n  \"url\": \"http://localhost/get\"\n}\n* Connection #0 to host localhost left intact\n```\n\nCheck the [access log](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/access_logging) in stdout.\n\n```console\n[2022-05-08T09:37:42.496Z] \"- - -\" 0 - 82 480 529 - \"-\" \"-\" \"-\" \"-\" \"72.44.59.17:80\"\n```\n\n## Dynamic configuration\n\n### Set up Envoy\n\nTo run a proxy:\n\n```console\n% docker run --rm envoyproxy/envoy:v1.22-latest --version\n\nenvoy  version: dcd329a2e95b54f754b17aceca3f72724294b502/1.22.0/Clean/RELEASE/BoringSSL\n\n% docker run --rm -p 10000:10000 -p 19901:19901 -v $PWD/envoy_dynamic:/etc/envoy envoyproxy/envoy:v1.22-latest -c /etc/envoy/bootstrap.yaml\n...\n[2022-04-24 07:39:54.948][1][info][config] [source/server/listener_manager_impl.cc:789] all dependencies initialized. starting workers\n```\n\nMake sure httpbin returns a response.\n\n```console\n% curl -v http://localhost:10000/get\n...\n  \"url\": \"http://localhost/get\"\n```\n\nMake sure the ready endpoint returns `LIVE`.\n\n```console\n% curl -v http://localhost:19901/ready\n...\n\u003c HTTP/1.1 200 OK\n\u003c content-type: text/plain; charset=UTF-8\n\u003c cache-control: no-cache, max-age=0\n\u003c x-content-type-options: nosniff\n\u003c date: Sun, 08 May 2022 11:55:47 GMT\n\u003c server: envoy\n\u003c x-envoy-upstream-service-time: 2\n\u003c transfer-encoding: chunked\n\u003c\nLIVE\n```\n\n### Change the config without restart\n\nChange the xDS config in the container.\n\n```console\n% docker ps -a\ndc1323f80ea2\n\n% docker exec dc1323f80ea2 sed -i -e 's/httpbin.org/google.com/' /etc/envoy/cds.yaml\n```\n\nCheck the log of Envoy container.\n\n```console\n[2022-04-24 07:58:50.477][1][info][upstream] [source/common/upstream/cds_api_helper.cc:30] cds: add 1 cluster(s), remove 0 cluster(s)\n[2022-04-24 07:58:50.479][1][info][upstream] [source/common/upstream/cds_api_helper.cc:67] cds: added/updated 1 cluster(s), skipped 0 unmodified cluster(s)\n```\n\nMake sure Google returns a response.\n\n```console\n% curl -v http://localhost:10000/get\n...\n  \u003ca href=//www.google.com/\u003e\u003cspan id=logo aria-label=Google\u003e\u003c/span\u003e\u003c/a\u003e\n```\n\n## Dynamic configuration (Kubernetes)\n\n### Set up\n\nCreate a cluster.\n\n```console\n% kind create cluster\n ✓ Ensuring node image (kindest/node:v1.23.4) 🖼\n ✓ Preparing nodes 📦\n...\n\n% kubectl version\nClient Version: version.Info{Major:\"1\", Minor:\"23\", GitVersion:\"v1.23.6\", GitCommit:\"ad3338546da947756e8a88aa6822e9c11e7eac22\", GitTreeState:\"clean\", BuildDate:\"2022-04-14T08:41:58Z\", GoVersion:\"go1.18.1\", Compiler:\"gc\", Platform:\"darwin/amd64\"}\nServer Version: version.Info{Major:\"1\", Minor:\"23\", GitVersion:\"v1.23.4\", GitCommit:\"e6c093d87ea4cbb530a7b2ae91e54c0842d8308a\", GitTreeState:\"clean\", BuildDate:\"2022-03-06T21:32:53Z\", GoVersion:\"go1.17.7\", Compiler:\"gc\", Platform:\"linux/amd64\"}\n```\n\nDeploy the Envoy.\n\n```console\n% kubectl create cm envoy --from-file=envoy_dynamic\nconfigmap/envoy created\n\n% kubectl apply -f envoy_deployment.yaml\ndeployment.apps/envoy created\n\n% kubectl get deployments envoy\nNAME    READY   UP-TO-DATE   AVAILABLE   AGE\nenvoy   1/1     1            1           54s\n\n% kubectl logs -l app=envoy\n...\n[2022-04-24 09:06:38.547][1][info][config] [source/server/listener_manager_impl.cc:789] all dependencies initialized. starting workers\n```\n\nMake sure httpbin returns a response.\n\n```console\n% kubectl port-forward \"$(kubectl get pods -l app=envoy -oname)\" 10000:10000\nForwarding from 127.0.0.1:10000 -\u003e 10000\nForwarding from [::1]:10000 -\u003e 10000\n\n% curl -v http://localhost:10000/get\n...\n  \"url\": \"http://localhost/get\"\n```\n\n### Change the config without restart\n\nChange the xDS config in the ConfigMap.\n\n```console\n% kubectl edit cm envoy\nconfigmap/envoy edited\n```\n\nCheck the log of Envoy container.\n\n```console\n% kubectl logs -l app=envoy\n...\n[2022-04-24 09:16:19.350][1][info][upstream] [source/common/upstream/cds_api_helper.cc:30] cds: add 1 cluster(s), remove 0 cluster(s)\n[2022-04-24 09:16:19.351][1][info][upstream] [source/common/upstream/cds_api_helper.cc:67] cds: added/updated 1 cluster(s), skipped 0 unmodified cluster(s)\n```\n\nMake sure Google returns a response.\n\n```console\n% curl -v http://localhost:10000/get\n...\n  \u003ca href=//www.google.com/\u003e\u003cspan id=logo aria-label=Google\u003e\u003c/span\u003e\u003c/a\u003e\n```\n\n### Clean up\n\nDelete the cluster.\n\n```console\n% kind delete cluster\nDeleting cluster \"kind\" ...\n```\n\n## :link: References\n\n- https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/listeners/tcp_proxy\n- https://www.envoyproxy.io/docs/envoy/latest/start/quick-start/run-envoy\n- https://www.envoyproxy.io/docs/envoy/latest/start/quick-start/configuration-dynamic-filesystem\n\nIf you are looking for a HTTP(S) proxy, see https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/http/http instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint128%2Fhello-envoy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fint128%2Fhello-envoy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint128%2Fhello-envoy/lists"}