Skip to content

Commit 9e3f6e3

Browse files
committed
Initial support for inference extension plugin
Signed-off-by: Daneyon Hansen <[email protected]>
1 parent 79f6948 commit 9e3f6e3

File tree

7 files changed

+1230
-6
lines changed

7 files changed

+1230
-6
lines changed

internal/kgateway/controller/start.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2"
2626
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/common"
2727
extensionsplug "github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/plugin"
28+
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/plugins/inferenceextension/endpointpicker"
2829
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/registry"
2930
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/settings"
3031
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/ir"
@@ -105,11 +106,6 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
105106
return nil, err
106107
}
107108

108-
// Extend the scheme if the InferencePool CRD exists.
109-
if _, err := glooschemes.AddInferExtV1A1Scheme(cfg.RestConfig, scheme); err != nil {
110-
return nil, err
111-
}
112-
113109
mgrOpts := ctrl.Options{
114110
BaseContext: func() context.Context { return ctx },
115111
Scheme: scheme,
@@ -148,6 +144,16 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
148144
setupLog,
149145
*cfg.SetupOpts.GlobalSettings,
150146
)
147+
148+
// Extend the scheme and add the EPP plugin if the InferencePool CRD exists.
149+
exists, err := glooschemes.AddInferExtV1A1Scheme(cfg.RestConfig, scheme)
150+
switch {
151+
case err != nil:
152+
return nil, err
153+
case exists:
154+
cfg.ExtraPlugins = append(cfg.ExtraPlugins, endpointpicker.NewPlugin(ctx, commoncol))
155+
}
156+
151157
gwClasses := sets.New(append(cfg.SetupOpts.ExtraGatewayClasses, wellknown.GatewayClassName)...)
152158
isOurGw := func(gw *apiv1.Gateway) bool {
153159
return gwClasses.Has(string(gw.Spec.GatewayClassName))

0 commit comments

Comments
 (0)