add extension service example project
This adds a demo project for an extension under the examples section. It's setup as a fully fledged project that can be used as a base or an example for creating an Envoy Gateway extension. The README.md file contains a walkthrough to deploy a pre-built image of the demo, and instructions for how you can build and modify it to suit your needs.
The example adds a custom resource GlobalLuaScript. The extension has a controller to watch these resources, and when it gets xDS modification hook requests from Envoy Gateway, it will inject HTTP filters for the lua script resources so that they run against all requests.
Example logs:
k logs eg-example-extension-6db8f55c44-d8cg4
4:15AM INF starting example Envoy Gateway extension service version: 0.6.0-dev built for linux/amd64...
4:15AM INF starting xds hooks server address=0.0.0.0:9000
4:15AM INF Reconciling GlobalLuaScript={"name":"example","namespace":"default"} controller=globalluascript controllerGroup=exampleorg.io controllerKind=GlobalLuaScript name=example namespace=default reconcileID=5fb7baf7-0825-4535-a8d2-368908025073
4:15AM INF reconcile triggered by GlobalLuaScript name=example namespace=default
4:15AM INF Reconcile successful GlobalLuaScript={"name":"example","namespace":"default"} controller=globalluascript controllerGroup=exampleorg.io controllerKind=GlobalLuaScript name=example namespace=default reconcileID=5fb7baf7-0825-4535-a8d2-368908025073
4:16AM INF handling xDS HTTP Listener modification request from Envoy Gateway
4:16AM INF injecting http lua filter for exampleorg.io.GlobalLuaFilter-default.example
4:16AM INF filters to be set for listener: {"number": 2} {"content": [name:"exampleorg.io.GlobalLuaFilter-default.example" typed_config:{[type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua]:{inline_code:"function envoy_on_response(response_handle)\n response_handle:headers():add(\"Lua-Script-Enabled\", \"Processed\")\nend\n"}} name:"envoy.filters.http.router" typed_config:{type_url:"type.googleapis.com/envoy.extensions.filters.http.router.v3.Router" value:" \x01"}]}
The README.md file shows how to setup the extension, configure Envoy Gateway to use it, and create an instance of a GlobalLuaScript that adds lua-script-enabled: Processed as a response header to all requests.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 64.59%. Comparing base (
23fa358) to head (5d38821). Report is 363 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2931 +/- ##
==========================================
+ Coverage 64.57% 64.59% +0.01%
==========================================
Files 122 122
Lines 21115 21115
==========================================
+ Hits 13636 13639 +3
+ Misses 6632 6630 -2
+ Partials 847 846 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
thanks for adding this @AliceProxy ! the community seems very interested into a strongly typed and programmatic way to program xds directly, and these docs should make it much easier to get them started @guydc @liorokman can you help with a review
thanks for adding this @AliceProxy ! the community seems very interested into a strongly typed and programmatic way to program xds directly, and these docs should make it much easier to get them started @guydc @liorokman can you help with a review
Right now this doesn't add any new docs to gateway.envoyproxy.io but if it gets to a point where we are happy with this and want to merge it then that write-up can be a follow-up task.
CI with the license check is failing and I'm not sure if we want to add the copyright comment to the go files within this example project or not since it's meant as a reference that community members can use as-is and modify, but I can add those in if we like.
The gen-check seems to be complaining about the go mod and go generation stuff used in here I haven't looked into that one much yet but it might make sense to try and have it ignore this directory.
FTR I'd vote for adding copyright -- Envoy Gateway is already Apache-2 licensed, which is pretty permissive.
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!
superseded by https://github.com/envoyproxy/gateway/pull/3788