Skip to content

cli: scaffolds 'aigw run' command#498

Merged
mathetake merged 15 commits intomainfrom
initialruncommand
Mar 19, 2025
Merged

cli: scaffolds 'aigw run' command#498
mathetake merged 15 commits intomainfrom
initialruncommand

Conversation

@mathetake
Copy link
Copy Markdown
Member

Commit Message

This scaffolds aigw run [path] command that allows users to run AI Gateway natively without k8s/docker.

Related Issues/PRs (if applicable)

Extracted from #458
Contributes to #412

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Copy Markdown
Member Author

envoyproxy/gateway#5505 is blocker for this

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Copy Markdown
Member Author

another one: envoyproxy/gateway#5538

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Copy Markdown
Member Author

🤞

@mathetake
Copy link
Copy Markdown
Member Author

finally!!!!!!!!!!!!!!!!!!

@mathetake mathetake marked this pull request as ready for review March 18, 2025 19:46
@mathetake mathetake requested a review from a team as a code owner March 18, 2025 19:46
@mathetake
Copy link
Copy Markdown
Member Author

@aabchoo could you take a quick look? This is just a skeleton (not actually running/translationg the AI resources) and just adds the Envoy Gateway integration with an empty configuration extracted from #458. It is a bit large but the more than half is go.sum/go.mod and auto generated contents which you can ignore.

maximum: 4294967295
minimum: 0
type: integer
perEndpoint:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is due to the upgrades of EG to the latest, so not directly relevant

github.com/envoyproxy/go-control-plane/envoy v1.32.5-0.20250303232259-0c5cb90447bb
github.com/go-logr/logr v1.4.2
github.com/google/cel-go v0.24.1
github.com/google/cel-go v0.22.1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was needed due to https://github.com/kubernetes/apiserver/issues/116 and need to pin it to 0.22.x until it's resolved

"github.com/stretchr/testify/require"
)

func TestRun_default(t *testing.T) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be expanded in the follow up #458

test-coverage:
@mkdir -p $(OUTPUT_DIR)
@$(MAKE) test GO_TEST_ARGS="-coverprofile=$(OUTPUT_DIR)/go-test-coverage.out -covermode=atomic -coverpkg=./... $(GO_TEST_ARGS)"
@$(MAKE) test GO_TEST_ARGS="-coverprofile=$(OUTPUT_DIR)/go-test-coverage.out -covermode=atomic -coverpkg=github.com/envoyproxy/ai-gateway/... $(GO_TEST_ARGS)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious: why this change?

Copy link
Copy Markdown
Member Author

@mathetake mathetake Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i should've left a note; envoyproxy/gateway is really a large project, hence generating the test coverage instrumented binary for it really take sa lot of time. So, simply this switches to do the instrumentation for the code in this repository (which is only thing we need in the first place for the test coverage report here).

// cmdRun corresponds to `aigw run` command.
cmdRun struct {
Debug bool `help:"Enable debug logging emitted to stderr."`
Path string `arg:"" name:"path" optional:"" help:"Path to the AI Gateway configuration yaml file. Optional. When this is not given, aigw runs the default configuration." type:"path"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be helpful for users to know the default config file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's my plan indeed. will do that in the next real implementation PR

@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDGDCCAgCgAwIBAgIEFZ8l4DANBgkqhkiG9w0BAQsFADAsMRYwFAYDVQQDEw1l
bnZveS1nYXRld2F5MRIwEAYDVQQFEwkzNjI3NTE0NTYwHhcNMjUwMzA0MDAzODA4
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanity check: do these certs never expire?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok good point....

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch and switched to do the cert gen on demand without checking them in. Now the code looks a bit simpler, thanks!

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
// Even after the context is done, the goroutine managing the Envoy process might be still trying to shut it down.
// Give it some time to do so, otherwise the process might become an orphan. This is the limitation of the current
// API of func-e library that is used by Envoy Gateway to run the Envoy process.
// TODO: actually fix the library and the EG accordingly.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be done after envoyproxy/gateway#5527 lands

Copy link
Copy Markdown
Contributor

@aabchoo aabchoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for doing this!

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake mathetake enabled auto-merge (squash) March 19, 2025 15:17
@mathetake mathetake merged commit e5c298e into main Mar 19, 2025
14 of 15 checks passed
@mathetake mathetake deleted the initialruncommand branch March 19, 2025 15:18
mathetake added a commit that referenced this pull request Mar 24, 2025
**Commit Message**

This implements the `aigw run` command that runs the AI Gateway locally.
This utilizes the Envoy Gateway's standalone mode [1]. With this
command, users are now able to use the AI Gateway, without Docker or
Kubernetes. The follow up PRs to further modify the default
configuration to add more de-facto services such as ollama, and will add
the command to show the default configuration.

1:
https://gateway.envoyproxy.io/docs/tasks/operations/standalone-deployment-mode/

**Related Issues/PRs (if applicable)**

Contributes to #412 
Follow up on #498

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants