Skip to content

Commit

Permalink
Initial support for inference extension plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Daneyon Hansen <[email protected]>
  • Loading branch information
danehans committed Feb 27, 2025
1 parent 79f6948 commit 9e3f6e3
Show file tree
Hide file tree
Showing 7 changed files with 1,230 additions and 6 deletions.
16 changes: 11 additions & 5 deletions internal/kgateway/controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2"
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/common"
extensionsplug "github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/plugin"
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/plugins/inferenceextension/endpointpicker"

Check failure on line 28 in internal/kgateway/controller/start.go

View workflow job for this annotation

GitHub Actions / Lint Checks

could not import github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/plugins/inferenceextension/endpointpicker (-: # github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/plugins/inferenceextension/endpointpicker
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/registry"
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/settings"
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/ir"
Expand Down Expand Up @@ -105,11 +106,6 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
return nil, err
}

// Extend the scheme if the InferencePool CRD exists.
if _, err := glooschemes.AddInferExtV1A1Scheme(cfg.RestConfig, scheme); err != nil {
return nil, err
}

mgrOpts := ctrl.Options{
BaseContext: func() context.Context { return ctx },
Scheme: scheme,
Expand Down Expand Up @@ -148,6 +144,16 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
setupLog,
*cfg.SetupOpts.GlobalSettings,
)

// Extend the scheme and add the EPP plugin if the InferencePool CRD exists.
exists, err := glooschemes.AddInferExtV1A1Scheme(cfg.RestConfig, scheme)
switch {
case err != nil:
return nil, err
case exists:
cfg.ExtraPlugins = append(cfg.ExtraPlugins, endpointpicker.NewPlugin(ctx, commoncol))
}

gwClasses := sets.New(append(cfg.SetupOpts.ExtraGatewayClasses, wellknown.GatewayClassName)...)
isOurGw := func(gw *apiv1.Gateway) bool {
return gwClasses.Has(string(gw.Spec.GatewayClassName))
Expand Down
Loading

0 comments on commit 9e3f6e3

Please sign in to comment.