diff --git a/api/v1/inferencepool_types.go b/api/v1/inferencepool_types.go index d2bcd9867..f53781675 100644 --- a/api/v1/inferencepool_types.go +++ b/api/v1/inferencepool_types.go @@ -75,9 +75,9 @@ type InferencePoolSpec struct { // +required TargetPorts []Port `json:"targetPorts,omitempty"` - // Extension configures an endpoint picker as an extension service. + // EndpointPickerRef configures an endpoint picker as an extension service. // +required - ExtensionRef Extension `json:"extensionRef,omitempty,omitzero"` + EndpointPickerRef EndpointPickerRef `json:"endpointPickerRef,omitempty,omitzero"` } // Port defines the network port that will be exposed by this InferencePool. @@ -90,7 +90,7 @@ type Port struct { } // Extension specifies how to configure an extension that runs the endpoint picker. -type Extension struct { +type EndpointPickerRef struct { // Group is the group of the referent. // The default value is "", representing the Core API group. // diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 1e20396d3..9e90d369f 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -26,7 +26,7 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Extension) DeepCopyInto(out *Extension) { +func (in *EndpointPickerRef) DeepCopyInto(out *EndpointPickerRef) { *out = *in if in.Group != nil { in, out := &in.Group, &out.Group @@ -40,12 +40,12 @@ func (in *Extension) DeepCopyInto(out *Extension) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extension. -func (in *Extension) DeepCopy() *Extension { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointPickerRef. +func (in *EndpointPickerRef) DeepCopy() *EndpointPickerRef { if in == nil { return nil } - out := new(Extension) + out := new(EndpointPickerRef) in.DeepCopyInto(out) return out } @@ -118,7 +118,7 @@ func (in *InferencePoolSpec) DeepCopyInto(out *InferencePoolSpec) { *out = make([]Port, len(*in)) copy(*out, *in) } - in.ExtensionRef.DeepCopyInto(&out.ExtensionRef) + in.EndpointPickerRef.DeepCopyInto(&out.EndpointPickerRef) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InferencePoolSpec. diff --git a/apix/v1alpha2/inferencepool_conversion.go b/apix/v1alpha2/inferencepool_conversion.go index aa29d8f69..b817c47d5 100644 --- a/apix/v1alpha2/inferencepool_conversion.go +++ b/apix/v1alpha2/inferencepool_conversion.go @@ -31,7 +31,7 @@ func (src *InferencePool) ConvertTo(dst *v1.InferencePool) error { if dst == nil { return errors.New("dst cannot be nil") } - v1Extension, err := convertExtensionRefToV1(&src.Spec.ExtensionRef) + endpointPickRef, err := convertExtensionRefToV1(&src.Spec.ExtensionRef) if err != nil { return err } @@ -42,7 +42,7 @@ func (src *InferencePool) ConvertTo(dst *v1.InferencePool) error { dst.TypeMeta = src.TypeMeta dst.ObjectMeta = src.ObjectMeta dst.Spec.TargetPorts = []v1.Port{{Number: v1.PortNumber(src.Spec.TargetPortNumber)}} - dst.Spec.ExtensionRef = v1Extension + dst.Spec.EndpointPickerRef = endpointPickRef dst.Status = *v1Status if src.Spec.Selector != nil { dst.Spec.Selector.MatchLabels = make(map[v1.LabelKey]v1.LabelValue, len(src.Spec.Selector)) @@ -58,7 +58,7 @@ func (dst *InferencePool) ConvertFrom(src *v1.InferencePool) error { if src == nil { return errors.New("src cannot be nil") } - extensionRef, err := convertExtensionRefFromV1(&src.Spec.ExtensionRef) + extensionRef, err := convertEndpointPickerRefFromV1(&src.Spec.EndpointPickerRef) if err != nil { return err } @@ -102,34 +102,53 @@ func convertStatusFromV1(src *v1.InferencePoolStatus) (*InferencePoolStatus, err return convert[InferencePoolStatus](u) } -func convertExtensionRefToV1(src *Extension) (v1.Extension, error) { +func convertExtensionRefToV1(src *Extension) (v1.EndpointPickerRef, error) { + endpointPickerRef := v1.EndpointPickerRef{} if src == nil { - return v1.Extension{}, errors.New("src cannot be nil") + return endpointPickerRef, errors.New("src cannot be nil") } - u, err := toUnstructured(src) - if err != nil { - return v1.Extension{}, err + if src.Group != nil { + v1Group := v1.Group(*src.Group) + endpointPickerRef.Group = &v1Group } - out, err := convert[v1.Extension](u) - if err != nil { - return v1.Extension{}, err + if src.Kind != nil { + endpointPickerRef.Kind = v1.Kind(*src.Kind) + } + endpointPickerRef.Name = v1.ObjectName(src.Name) + if src.PortNumber != nil { + v1PortNumber := v1.PortNumber(*src.PortNumber) + endpointPickerRef.PortNumber = &v1PortNumber + } + if src.FailureMode != nil { + endpointPickerRef.FailureMode = v1.ExtensionFailureMode(*src.FailureMode) } - return *out, nil + + return endpointPickerRef, nil } -func convertExtensionRefFromV1(src *v1.Extension) (Extension, error) { +func convertEndpointPickerRefFromV1(src *v1.EndpointPickerRef) (Extension, error) { + extension := Extension{} if src == nil { - return Extension{}, errors.New("src cannot be nil") + return extension, errors.New("src cannot be nil") } - u, err := toUnstructured(&src) - if err != nil { - return Extension{}, err + if src.Group != nil { + group := Group(*src.Group) + extension.Group = &group } - extension, err := convert[Extension](u) - if err != nil { - return Extension{}, err + if src.Kind != "" { + kind := Kind(src.Kind) + extension.Kind = &kind + } + extension.Name = ObjectName(src.Name) + if src.PortNumber != nil { + portNumber := PortNumber(*src.PortNumber) + extension.PortNumber = &portNumber + } + if src.FailureMode != "" { + extensionFailureMode := ExtensionFailureMode(src.FailureMode) + extension.FailureMode = &extensionFailureMode } - return *extension, nil + return extension, nil } func toUnstructured(obj any) (*unstructured.Unstructured, error) { diff --git a/apix/v1alpha2/inferencepool_conversion_test.go b/apix/v1alpha2/inferencepool_conversion_test.go index 8da8c0f4d..2c59fc632 100644 --- a/apix/v1alpha2/inferencepool_conversion_test.go +++ b/apix/v1alpha2/inferencepool_conversion_test.go @@ -100,7 +100,7 @@ func TestInferencePoolConvertTo(t *testing.T) { }, }, TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8080))}}, - ExtensionRef: v1.Extension{ + EndpointPickerRef: v1.EndpointPickerRef{ Group: &v1Group, Kind: v1Kind, Name: "my-epp-service", @@ -235,7 +235,7 @@ func TestInferencePoolConvertFrom(t *testing.T) { }, }, TargetPorts: []v1.Port{{Number: v1.PortNumber(int32(8080))}}, - ExtensionRef: v1.Extension{ + EndpointPickerRef: v1.EndpointPickerRef{ Group: &v1Group, Kind: v1Kind, Name: "my-epp-service", diff --git a/client-go/applyconfiguration/api/v1/extension.go b/client-go/applyconfiguration/api/v1/endpointpickerref.go similarity index 72% rename from client-go/applyconfiguration/api/v1/extension.go rename to client-go/applyconfiguration/api/v1/endpointpickerref.go index 7e7d645c8..8e82230bd 100644 --- a/client-go/applyconfiguration/api/v1/extension.go +++ b/client-go/applyconfiguration/api/v1/endpointpickerref.go @@ -22,9 +22,9 @@ import ( apiv1 "sigs.k8s.io/gateway-api-inference-extension/api/v1" ) -// ExtensionApplyConfiguration represents a declarative configuration of the Extension type for use +// EndpointPickerRefApplyConfiguration represents a declarative configuration of the EndpointPickerRef type for use // with apply. -type ExtensionApplyConfiguration struct { +type EndpointPickerRefApplyConfiguration struct { Group *apiv1.Group `json:"group,omitempty"` Kind *apiv1.Kind `json:"kind,omitempty"` Name *apiv1.ObjectName `json:"name,omitempty"` @@ -32,16 +32,16 @@ type ExtensionApplyConfiguration struct { FailureMode *apiv1.ExtensionFailureMode `json:"failureMode,omitempty"` } -// ExtensionApplyConfiguration constructs a declarative configuration of the Extension type for use with +// EndpointPickerRefApplyConfiguration constructs a declarative configuration of the EndpointPickerRef type for use with // apply. -func Extension() *ExtensionApplyConfiguration { - return &ExtensionApplyConfiguration{} +func EndpointPickerRef() *EndpointPickerRefApplyConfiguration { + return &EndpointPickerRefApplyConfiguration{} } // WithGroup sets the Group field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Group field is set to the value of the last call. -func (b *ExtensionApplyConfiguration) WithGroup(value apiv1.Group) *ExtensionApplyConfiguration { +func (b *EndpointPickerRefApplyConfiguration) WithGroup(value apiv1.Group) *EndpointPickerRefApplyConfiguration { b.Group = &value return b } @@ -49,7 +49,7 @@ func (b *ExtensionApplyConfiguration) WithGroup(value apiv1.Group) *ExtensionApp // WithKind sets the Kind field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Kind field is set to the value of the last call. -func (b *ExtensionApplyConfiguration) WithKind(value apiv1.Kind) *ExtensionApplyConfiguration { +func (b *EndpointPickerRefApplyConfiguration) WithKind(value apiv1.Kind) *EndpointPickerRefApplyConfiguration { b.Kind = &value return b } @@ -57,7 +57,7 @@ func (b *ExtensionApplyConfiguration) WithKind(value apiv1.Kind) *ExtensionApply // WithName sets the Name field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the Name field is set to the value of the last call. -func (b *ExtensionApplyConfiguration) WithName(value apiv1.ObjectName) *ExtensionApplyConfiguration { +func (b *EndpointPickerRefApplyConfiguration) WithName(value apiv1.ObjectName) *EndpointPickerRefApplyConfiguration { b.Name = &value return b } @@ -65,7 +65,7 @@ func (b *ExtensionApplyConfiguration) WithName(value apiv1.ObjectName) *Extensio // WithPortNumber sets the PortNumber field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the PortNumber field is set to the value of the last call. -func (b *ExtensionApplyConfiguration) WithPortNumber(value apiv1.PortNumber) *ExtensionApplyConfiguration { +func (b *EndpointPickerRefApplyConfiguration) WithPortNumber(value apiv1.PortNumber) *EndpointPickerRefApplyConfiguration { b.PortNumber = &value return b } @@ -73,7 +73,7 @@ func (b *ExtensionApplyConfiguration) WithPortNumber(value apiv1.PortNumber) *Ex // WithFailureMode sets the FailureMode field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the FailureMode field is set to the value of the last call. -func (b *ExtensionApplyConfiguration) WithFailureMode(value apiv1.ExtensionFailureMode) *ExtensionApplyConfiguration { +func (b *EndpointPickerRefApplyConfiguration) WithFailureMode(value apiv1.ExtensionFailureMode) *EndpointPickerRefApplyConfiguration { b.FailureMode = &value return b } diff --git a/client-go/applyconfiguration/api/v1/inferencepoolspec.go b/client-go/applyconfiguration/api/v1/inferencepoolspec.go index 364d059dd..ca4498749 100644 --- a/client-go/applyconfiguration/api/v1/inferencepoolspec.go +++ b/client-go/applyconfiguration/api/v1/inferencepoolspec.go @@ -21,9 +21,9 @@ package v1 // InferencePoolSpecApplyConfiguration represents a declarative configuration of the InferencePoolSpec type for use // with apply. type InferencePoolSpecApplyConfiguration struct { - Selector *LabelSelectorApplyConfiguration `json:"selector,omitempty"` - TargetPorts []PortApplyConfiguration `json:"targetPorts,omitempty"` - ExtensionRef *ExtensionApplyConfiguration `json:"extensionRef,omitempty"` + Selector *LabelSelectorApplyConfiguration `json:"selector,omitempty"` + TargetPorts []PortApplyConfiguration `json:"targetPorts,omitempty"` + EndpointPickerRef *EndpointPickerRefApplyConfiguration `json:"endpointPickerRef,omitempty"` } // InferencePoolSpecApplyConfiguration constructs a declarative configuration of the InferencePoolSpec type for use with @@ -53,10 +53,10 @@ func (b *InferencePoolSpecApplyConfiguration) WithTargetPorts(values ...*PortApp return b } -// WithExtensionRef sets the ExtensionRef field in the declarative configuration to the given value +// WithEndpointPickerRef sets the EndpointPickerRef field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the ExtensionRef field is set to the value of the last call. -func (b *InferencePoolSpecApplyConfiguration) WithExtensionRef(value *ExtensionApplyConfiguration) *InferencePoolSpecApplyConfiguration { - b.ExtensionRef = value +// If called multiple times, the EndpointPickerRef field is set to the value of the last call. +func (b *InferencePoolSpecApplyConfiguration) WithEndpointPickerRef(value *EndpointPickerRefApplyConfiguration) *InferencePoolSpecApplyConfiguration { + b.EndpointPickerRef = value return b } diff --git a/client-go/applyconfiguration/utils.go b/client-go/applyconfiguration/utils.go index c5d4f575e..8a3b6b384 100644 --- a/client-go/applyconfiguration/utils.go +++ b/client-go/applyconfiguration/utils.go @@ -34,8 +34,8 @@ import ( func ForKind(kind schema.GroupVersionKind) interface{} { switch kind { // Group=inference.networking.k8s.io, Version=v1 - case v1.SchemeGroupVersion.WithKind("Extension"): - return &apiv1.ExtensionApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("EndpointPickerRef"): + return &apiv1.EndpointPickerRefApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("InferencePool"): return &apiv1.InferencePoolApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("InferencePoolSpec"): diff --git a/config/charts/inferencepool/templates/inferencepool.yaml b/config/charts/inferencepool/templates/inferencepool.yaml index ad13f2d43..27e6f72f1 100644 --- a/config/charts/inferencepool/templates/inferencepool.yaml +++ b/config/charts/inferencepool/templates/inferencepool.yaml @@ -18,5 +18,5 @@ spec: {{ $key }}: {{ quote $value }} {{- end }} {{- end }} - extensionRef: + endpointPickerRef: name: {{ include "gateway-api-inference-extension.name" . }} diff --git a/config/crd/bases/inference.networking.k8s.io_inferencepools.yaml b/config/crd/bases/inference.networking.k8s.io_inferencepools.yaml index 25e0a4d3f..11ae46987 100644 --- a/config/crd/bases/inference.networking.k8s.io_inferencepools.yaml +++ b/config/crd/bases/inference.networking.k8s.io_inferencepools.yaml @@ -43,9 +43,9 @@ spec: spec: description: InferencePoolSpec defines the desired state of InferencePool properties: - extensionRef: - description: Extension configures an endpoint picker as an extension - service. + endpointPickerRef: + description: EndpointPickerRef configures an endpoint picker as an + extension service. properties: failureMode: default: FailClose @@ -158,7 +158,7 @@ spec: type: array x-kubernetes-list-type: atomic required: - - extensionRef + - endpointPickerRef - selector - targetPorts type: object diff --git a/config/manifests/inferencepool-resources.yaml b/config/manifests/inferencepool-resources.yaml index a3eba5582..7c31da97e 100644 --- a/config/manifests/inferencepool-resources.yaml +++ b/config/manifests/inferencepool-resources.yaml @@ -13,7 +13,7 @@ spec: selector: matchLabels: app: vllm-llama3-8b-instruct - extensionRef: + endpointPickerRef: name: vllm-llama3-8b-instruct-epp --- apiVersion: v1 diff --git a/conformance/resources/base.yaml b/conformance/resources/base.yaml index 6ac6dd07c..4fd3b3831 100644 --- a/conformance/resources/base.yaml +++ b/conformance/resources/base.yaml @@ -157,7 +157,7 @@ spec: app: primary-inference-model-server targetPorts: - number: 3000 - extensionRef: + endpointPickerRef: name: primary-endpoint-picker-svc --- # --- Primary Conformance EPP service Definition --- @@ -252,7 +252,7 @@ spec: app: secondary-inference-model-server targetPorts: - number: 3000 - extensionRef: + endpointPickerRef: name: secondary-endpoint-picker-svc failureMode: FailOpen --- diff --git a/conformance/tests/inferencepool_invalid_epp_service.yaml b/conformance/tests/inferencepool_invalid_epp_service.yaml index 1ba5eb8b9..cdc2048f7 100644 --- a/conformance/tests/inferencepool_invalid_epp_service.yaml +++ b/conformance/tests/inferencepool_invalid_epp_service.yaml @@ -9,7 +9,7 @@ spec: app: primary-inference-model-server targetPorts: - number: 3000 - extensionRef: + endpointPickerRef: name: non-existent-epp-svc --- apiVersion: gateway.networking.k8s.io/v1 diff --git a/pkg/epp/controller/inferencepool_reconciler_test.go b/pkg/epp/controller/inferencepool_reconciler_test.go index 48d508389..7f6938533 100644 --- a/pkg/epp/controller/inferencepool_reconciler_test.go +++ b/pkg/epp/controller/inferencepool_reconciler_test.go @@ -81,9 +81,9 @@ func TestInferencePoolReconciler(t *testing.T) { Namespace("pool1-ns"). Selector(selector_v1). TargetPorts(8080). - ExtensionRef("epp-service").ObjRef() + EndpointPickerRef("epp-service").ObjRef() pool1.SetGroupVersionKind(gvk) - pool2 := utiltest.MakeInferencePool("pool2").Namespace("pool2-ns").ExtensionRef("epp-service").ObjRef() + pool2 := utiltest.MakeInferencePool("pool2").Namespace("pool2-ns").EndpointPickerRef("epp-service").ObjRef() pool2.SetGroupVersionKind(gvk) // Set up the scheme. diff --git a/pkg/epp/util/testing/wrappers.go b/pkg/epp/util/testing/wrappers.go index 9eeb3ad9d..9e7f4a17b 100644 --- a/pkg/epp/util/testing/wrappers.go +++ b/pkg/epp/util/testing/wrappers.go @@ -205,8 +205,8 @@ func (m *InferencePoolWrapper) TargetPorts(p int32) *InferencePoolWrapper { return m } -func (m *InferencePoolWrapper) ExtensionRef(name string) *InferencePoolWrapper { - m.Spec.ExtensionRef = v1.Extension{Name: v1.ObjectName(name)} +func (m *InferencePoolWrapper) EndpointPickerRef(name string) *InferencePoolWrapper { + m.Spec.EndpointPickerRef = v1.EndpointPickerRef{Name: v1.ObjectName(name)} return m } diff --git a/test/testdata/inferencepool-e2e.yaml b/test/testdata/inferencepool-e2e.yaml index 7c546ba37..9fa50593a 100644 --- a/test/testdata/inferencepool-e2e.yaml +++ b/test/testdata/inferencepool-e2e.yaml @@ -9,7 +9,7 @@ spec: selector: matchLabels: app: vllm-llama3-8b-instruct - extensionRef: + endpointPickerRef: name: vllm-llama3-8b-instruct-epp namespace: $E2E_NS --- diff --git a/test/testdata/inferencepool-leader-election-e2e.yaml b/test/testdata/inferencepool-leader-election-e2e.yaml index 413fa55d9..8c243470f 100644 --- a/test/testdata/inferencepool-leader-election-e2e.yaml +++ b/test/testdata/inferencepool-leader-election-e2e.yaml @@ -7,7 +7,7 @@ spec: targetPortNumber: 8000 selector: app: vllm-llama3-8b-instruct - extensionRef: + endpointPickerRef: name: vllm-llama3-8b-instruct-epp namespace: $E2E_NS --- diff --git a/test/testdata/inferencepool-with-model-hermetic.yaml b/test/testdata/inferencepool-with-model-hermetic.yaml index 20fea8d1a..794b7fcd4 100644 --- a/test/testdata/inferencepool-with-model-hermetic.yaml +++ b/test/testdata/inferencepool-with-model-hermetic.yaml @@ -9,7 +9,7 @@ spec: selector: matchLabels: app: vllm-llama3-8b-instruct-pool - extensionRef: + endpointPickerRef: name: epp --- apiVersion: inference.networking.x-k8s.io/v1alpha2