Skip to content

cli: initial implementation of aigw run#458

Merged
mathetake merged 63 commits intomainfrom
standalonemode
Mar 24, 2025
Merged

cli: initial implementation of aigw run#458
mathetake merged 63 commits intomainfrom
standalonemode

Conversation

@mathetake
Copy link
Copy Markdown
Member

@mathetake mathetake commented Mar 5, 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>
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 added a commit that referenced this pull request Mar 5, 2025
**Commit Message**

The CLI's standalone mode needs to use Envoy Gateway's latest patch [1]
that allows us to use it inside our CLI. This upgrades the EG dependency
version to the latest. It is not compatible with the latest cel-go, so
this also pins it to 0.22 until the upstream k8s.io/apiserver dependency
[2] issue is resolved. This commit is separated from the standalone
implementation commit as the upgrade results in a CRD generation which
is not relevant to the change.

1: envoyproxy/gateway#5407
2: https://github.com/kubernetes/apiserver/issues/116

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

This is a preparation for #458

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

a couple of things not working with EG standalone mode, so I might want to switch to the raw Envoy with func-e

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

finally working

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 added a commit that referenced this pull request Mar 12, 2025
**Commit Message**

This makes changes to Main function of the extproc so that it will
accept context as well as args, etc to allow the callsite to fine tune
the behavior of extproc.

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

Extracted from #458

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

@aabchoo could you take a quick look again? now it's working end-to-end. As I noted in the description, i will do the followup on the additional flags (like the one you suggested to show default configuration etc) + documentation. This is really exciting stuff

@mathetake mathetake requested a review from aabchoo March 20, 2025 00:22
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Copy Markdown
Member Author

i think i will add the code including the showcase one since i have some time until aaron can review;) @aabchoo forgive me to make this PR a bit giant beyond i normally feel comfortable with asking for review 😄

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>
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>
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.

looks good to me


for i := range extensionPolicies.Items {
ep := &extensionPolicies.Items[i]
if len(ep.OwnerReferences) != 1 || ep.OwnerReferences[0].Kind != "AIGatewayRoute" || ep.OwnerReferences[0].APIVersion != "aigateway.envoyproxy.io/v1alpha1" {
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.

Is it possible for ep.OwnerReferences size is 0?

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.

that's a bug in the controller or user created extension policies. That's why it's skipped one line below

if len(extProc.BackendRefs) != 1 {
panic(fmt.Sprintf("BUG: unexpected number of backend refs: %d", len(extProc.BackendRefs)))
}
backendRef := &extProc.BackendRefs[0]
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.

why do we only support one backendref?

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 the extproc's backend ref so it's always exactly one backend ref. This is not user defined backend ref.

mustWriteObj(&backend.TypeMeta, backend, runCtx.envoyGatewayResourcesOut)
backendRef.Group = ptr.To[gwapiv1.Group]("gateway.envoyproxy.io")
backendRef.Kind = ptr.To[gwapiv1.Kind]("Backend")
backendRef.Port = nil
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.

not port defined above?

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.

BackendReference's Port is only for the case where the target is k8s Service, which is not the case here (BackendRef's API doc):

Port is required when the referent is a Kubernetes Service.

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 mathetake enabled auto-merge (squash) March 24, 2025 16:09
@mathetake mathetake merged commit 9dc0c98 into main Mar 24, 2025
15 checks passed
@mathetake mathetake deleted the standalonemode branch March 24, 2025 16:11
@mathetake
Copy link
Copy Markdown
Member Author

@aabchoo thanks for the look!!

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