From 698b43344671718c5b64714fe02f1f82e24564b8 Mon Sep 17 00:00:00 2001 From: Daneyon Hansen Date: Tue, 18 Feb 2025 10:40:23 -0800 Subject: [PATCH] Adds Initial InferencePool Support to GatewayParameters Signed-off-by: Daneyon Hansen --- .../api/v1alpha1/endpointpickerextension.go | 23 +++++++++ .../api/v1alpha1/inferenceextension.go | 23 +++++++++ .../api/v1alpha1/kubernetesproxyconfig.go | 29 +++++++---- api/applyconfiguration/internal/internal.go | 15 ++++++ api/applyconfiguration/utils.go | 4 ++ api/v1alpha1/gateway_parameters_types.go | 23 +++++++++ api/v1alpha1/zz_generated.deepcopy.go | 45 ++++++++++++++++ ...ateway.kgateway.dev_gatewayparameters.yaml | 8 +++ pkg/generated/openapi/zz_generated.openapi.go | 51 ++++++++++++++++++- 9 files changed, 210 insertions(+), 11 deletions(-) create mode 100644 api/applyconfiguration/api/v1alpha1/endpointpickerextension.go create mode 100644 api/applyconfiguration/api/v1alpha1/inferenceextension.go diff --git a/api/applyconfiguration/api/v1alpha1/endpointpickerextension.go b/api/applyconfiguration/api/v1alpha1/endpointpickerextension.go new file mode 100644 index 00000000000..60df11f146f --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/endpointpickerextension.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// EndpointPickerExtensionApplyConfiguration represents a declarative configuration of the EndpointPickerExtension type for use +// with apply. +type EndpointPickerExtensionApplyConfiguration struct { + Enabled *bool `json:"enabled,omitempty"` +} + +// EndpointPickerExtensionApplyConfiguration constructs a declarative configuration of the EndpointPickerExtension type for use with +// apply. +func EndpointPickerExtension() *EndpointPickerExtensionApplyConfiguration { + return &EndpointPickerExtensionApplyConfiguration{} +} + +// WithEnabled sets the Enabled 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 Enabled field is set to the value of the last call. +func (b *EndpointPickerExtensionApplyConfiguration) WithEnabled(value bool) *EndpointPickerExtensionApplyConfiguration { + b.Enabled = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/inferenceextension.go b/api/applyconfiguration/api/v1alpha1/inferenceextension.go new file mode 100644 index 00000000000..801ee3eb4e4 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/inferenceextension.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// InferenceExtensionApplyConfiguration represents a declarative configuration of the InferenceExtension type for use +// with apply. +type InferenceExtensionApplyConfiguration struct { + EndpointPicker *EndpointPickerExtensionApplyConfiguration `json:"endpointPicker,omitempty"` +} + +// InferenceExtensionApplyConfiguration constructs a declarative configuration of the InferenceExtension type for use with +// apply. +func InferenceExtension() *InferenceExtensionApplyConfiguration { + return &InferenceExtensionApplyConfiguration{} +} + +// WithEndpointPicker sets the EndpointPicker 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 EndpointPicker field is set to the value of the last call. +func (b *InferenceExtensionApplyConfiguration) WithEndpointPicker(value *EndpointPickerExtensionApplyConfiguration) *InferenceExtensionApplyConfiguration { + b.EndpointPicker = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/kubernetesproxyconfig.go b/api/applyconfiguration/api/v1alpha1/kubernetesproxyconfig.go index 8ec99b0bd3f..c1d33a2908d 100644 --- a/api/applyconfiguration/api/v1alpha1/kubernetesproxyconfig.go +++ b/api/applyconfiguration/api/v1alpha1/kubernetesproxyconfig.go @@ -5,16 +5,17 @@ package v1alpha1 // KubernetesProxyConfigApplyConfiguration represents a declarative configuration of the KubernetesProxyConfig type for use // with apply. type KubernetesProxyConfigApplyConfiguration struct { - Deployment *ProxyDeploymentApplyConfiguration `json:"deployment,omitempty"` - EnvoyContainer *EnvoyContainerApplyConfiguration `json:"envoyContainer,omitempty"` - SdsContainer *SdsContainerApplyConfiguration `json:"sdsContainer,omitempty"` - PodTemplate *PodApplyConfiguration `json:"podTemplate,omitempty"` - Service *ServiceApplyConfiguration `json:"service,omitempty"` - ServiceAccount *ServiceAccountApplyConfiguration `json:"serviceAccount,omitempty"` - Istio *IstioIntegrationApplyConfiguration `json:"istio,omitempty"` - Stats *StatsConfigApplyConfiguration `json:"stats,omitempty"` - AiExtension *AiExtensionApplyConfiguration `json:"aiExtension,omitempty"` - FloatingUserId *bool `json:"floatingUserId,omitempty"` + Deployment *ProxyDeploymentApplyConfiguration `json:"deployment,omitempty"` + EnvoyContainer *EnvoyContainerApplyConfiguration `json:"envoyContainer,omitempty"` + SdsContainer *SdsContainerApplyConfiguration `json:"sdsContainer,omitempty"` + PodTemplate *PodApplyConfiguration `json:"podTemplate,omitempty"` + Service *ServiceApplyConfiguration `json:"service,omitempty"` + ServiceAccount *ServiceAccountApplyConfiguration `json:"serviceAccount,omitempty"` + Istio *IstioIntegrationApplyConfiguration `json:"istio,omitempty"` + Stats *StatsConfigApplyConfiguration `json:"stats,omitempty"` + AiExtension *AiExtensionApplyConfiguration `json:"aiExtension,omitempty"` + InferenceExtension *InferenceExtensionApplyConfiguration `json:"inferenceExtension,omitempty"` + FloatingUserId *bool `json:"floatingUserId,omitempty"` } // KubernetesProxyConfigApplyConfiguration constructs a declarative configuration of the KubernetesProxyConfig type for use with @@ -95,6 +96,14 @@ func (b *KubernetesProxyConfigApplyConfiguration) WithAiExtension(value *AiExten return b } +// WithInferenceExtension sets the InferenceExtension 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 InferenceExtension field is set to the value of the last call. +func (b *KubernetesProxyConfigApplyConfiguration) WithInferenceExtension(value *InferenceExtensionApplyConfiguration) *KubernetesProxyConfigApplyConfiguration { + b.InferenceExtension = value + return b +} + // WithFloatingUserId sets the FloatingUserId 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 FloatingUserId field is set to the value of the last call. diff --git a/api/applyconfiguration/internal/internal.go b/api/applyconfiguration/internal/internal.go index e4656435509..fde7bbbaf3d 100644 --- a/api/applyconfiguration/internal/internal.go +++ b/api/applyconfiguration/internal/internal.go @@ -199,6 +199,12 @@ var schemaYAML = typed.YAMLObject(`types: - name: value type: scalar: numeric +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.EndpointPickerExtension + map: + fields: + - name: enabled + type: + scalar: boolean - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.EnvoyBootstrap map: fields: @@ -429,6 +435,12 @@ var schemaYAML = typed.YAMLObject(`types: - name: tag type: scalar: string +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.InferenceExtension + map: + fields: + - name: endpointPicker + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.EndpointPickerExtension - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.IstioContainer map: fields: @@ -480,6 +492,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: floatingUserId type: scalar: boolean + - name: inferenceExtension + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.InferenceExtension - name: istio type: namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.IstioIntegration diff --git a/api/applyconfiguration/utils.go b/api/applyconfiguration/utils.go index 8541082b252..f0c11ae709c 100644 --- a/api/applyconfiguration/utils.go +++ b/api/applyconfiguration/utils.go @@ -37,6 +37,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.DirectResponseSpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("DurationFilter"): return &apiv1alpha1.DurationFilterApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("EndpointPickerExtension"): + return &apiv1alpha1.EndpointPickerExtensionApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("EnvoyBootstrap"): return &apiv1alpha1.EnvoyBootstrapApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("EnvoyContainer"): @@ -65,6 +67,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.HTTPListenerPolicySpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("Image"): return &apiv1alpha1.ImageApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InferenceExtension"): + return &apiv1alpha1.InferenceExtensionApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("IstioContainer"): return &apiv1alpha1.IstioContainerApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("IstioIntegration"): diff --git a/api/v1alpha1/gateway_parameters_types.go b/api/v1alpha1/gateway_parameters_types.go index b64328c8176..8e5cf45c23e 100644 --- a/api/v1alpha1/gateway_parameters_types.go +++ b/api/v1alpha1/gateway_parameters_types.go @@ -106,6 +106,12 @@ type KubernetesProxyConfig struct { // +kubebuilder:validation:Optional AiExtension *AiExtension `json:"aiExtension,omitempty"` + // InferenceExtension defines the desired state of the Gateway API inference extension. + // For additional details, see: https://gateway-api-inference-extension.sigs.k8s.io/. + // + // +kubebuilder:validation:Optional + InferenceExtension *InferenceExtension `json:"inferenceExtension,omitempty"` + // Used to unset the `runAsUser` values in security contexts. FloatingUserId *bool `json:"floatingUserId,omitempty"` } @@ -732,3 +738,20 @@ func (in *CustomLabel) GetKeyDelimiter() *string { } return in.KeyDelimiter } + +// InferenceExtension defines the desired state of the Gateway API inference extension. +// For additional details, see: https://gateway-api-inference-extension.sigs.k8s.io/. +type InferenceExtension struct { + // EndpointPicker defines the EndpointPicker extension. + // + // +optional + EndpointPicker *EndpointPickerExtension `json:"endpointPicker,omitempty"` +} + +// EndpointPickerExtension defines the desired state of an EndpointPicker extension. +type EndpointPickerExtension struct { + // Whether to enable the extension. + // + // +kubebuilder:validation:Optional + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index a1c5f0eda46..f28800dc364 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -328,6 +328,26 @@ func (in *DurationFilter) DeepCopy() *DurationFilter { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointPickerExtension) DeepCopyInto(out *EndpointPickerExtension) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointPickerExtension. +func (in *EndpointPickerExtension) DeepCopy() *EndpointPickerExtension { + if in == nil { + return nil + } + out := new(EndpointPickerExtension) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EnvoyBootstrap) DeepCopyInto(out *EnvoyBootstrap) { *out = *in @@ -787,6 +807,26 @@ func (in *Image) DeepCopy() *Image { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InferenceExtension) DeepCopyInto(out *InferenceExtension) { + *out = *in + if in.EndpointPicker != nil { + in, out := &in.EndpointPicker, &out.EndpointPicker + *out = new(EndpointPickerExtension) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InferenceExtension. +func (in *InferenceExtension) DeepCopy() *InferenceExtension { + if in == nil { + return nil + } + out := new(InferenceExtension) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IstioContainer) DeepCopyInto(out *IstioContainer) { *out = *in @@ -912,6 +952,11 @@ func (in *KubernetesProxyConfig) DeepCopyInto(out *KubernetesProxyConfig) { *out = new(AiExtension) (*in).DeepCopyInto(*out) } + if in.InferenceExtension != nil { + in, out := &in.InferenceExtension, &out.InferenceExtension + *out = new(InferenceExtension) + (*in).DeepCopyInto(*out) + } if in.FloatingUserId != nil { in, out := &in.FloatingUserId, &out.FloatingUserId *out = new(bool) diff --git a/install/helm/kgateway/crds/gateway.kgateway.dev_gatewayparameters.yaml b/install/helm/kgateway/crds/gateway.kgateway.dev_gatewayparameters.yaml index 71b2e8ea77f..c8a78aed510 100644 --- a/install/helm/kgateway/crds/gateway.kgateway.dev_gatewayparameters.yaml +++ b/install/helm/kgateway/crds/gateway.kgateway.dev_gatewayparameters.yaml @@ -406,6 +406,14 @@ spec: type: object floatingUserId: type: boolean + inferenceExtension: + properties: + endpointPicker: + properties: + enabled: + type: boolean + type: object + type: object istio: properties: customSidecars: diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 7ce2f5911e4..19c31c365df 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -29,6 +29,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.DirectResponseSpec": schema_kgateway_v2_api_v1alpha1_DirectResponseSpec(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.DirectResponseStatus": schema_kgateway_v2_api_v1alpha1_DirectResponseStatus(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.DurationFilter": schema_kgateway_v2_api_v1alpha1_DurationFilter(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EndpointPickerExtension": schema_kgateway_v2_api_v1alpha1_EndpointPickerExtension(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EnvoyBootstrap": schema_kgateway_v2_api_v1alpha1_EnvoyBootstrap(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EnvoyContainer": schema_kgateway_v2_api_v1alpha1_EnvoyContainer(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.FileSink": schema_kgateway_v2_api_v1alpha1_FileSink(ref), @@ -46,6 +47,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.HeaderFilter": schema_kgateway_v2_api_v1alpha1_HeaderFilter(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host": schema_kgateway_v2_api_v1alpha1_Host(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Image": schema_kgateway_v2_api_v1alpha1_Image(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.InferenceExtension": schema_kgateway_v2_api_v1alpha1_InferenceExtension(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.IstioContainer": schema_kgateway_v2_api_v1alpha1_IstioContainer(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.IstioIntegration": schema_kgateway_v2_api_v1alpha1_IstioIntegration(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.KubernetesProxyConfig": schema_kgateway_v2_api_v1alpha1_KubernetesProxyConfig(ref), @@ -923,6 +925,26 @@ func schema_kgateway_v2_api_v1alpha1_DurationFilter(ref common.ReferenceCallback } } +func schema_kgateway_v2_api_v1alpha1_EndpointPickerExtension(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "EndpointPickerExtension defines the desired state of an EndpointPicker extension.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "enabled": { + SchemaProps: spec.SchemaProps{ + Description: "Whether to enable the extension.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + func schema_kgateway_v2_api_v1alpha1_EnvoyBootstrap(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1593,6 +1615,27 @@ func schema_kgateway_v2_api_v1alpha1_Image(ref common.ReferenceCallback) common. } } +func schema_kgateway_v2_api_v1alpha1_InferenceExtension(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InferenceExtension defines the desired state of the Gateway API inference extension. For additional details, see: https://gateway-api-inference-extension.sigs.k8s.io/.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "endpointPicker": { + SchemaProps: spec.SchemaProps{ + Description: "EndpointPicker defines the EndpointPicker extension.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EndpointPickerExtension"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EndpointPickerExtension"}, + } +} + func schema_kgateway_v2_api_v1alpha1_IstioContainer(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1750,6 +1793,12 @@ func schema_kgateway_v2_api_v1alpha1_KubernetesProxyConfig(ref common.ReferenceC Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AiExtension"), }, }, + "inferenceExtension": { + SchemaProps: spec.SchemaProps{ + Description: "InferenceExtension defines the desired state of the Gateway API inference extension. For additional details, see: https://gateway-api-inference-extension.sigs.k8s.io/.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.InferenceExtension"), + }, + }, "floatingUserId": { SchemaProps: spec.SchemaProps{ Description: "Used to unset the `runAsUser` values in security contexts.", @@ -1761,7 +1810,7 @@ func schema_kgateway_v2_api_v1alpha1_KubernetesProxyConfig(ref common.ReferenceC }, }, Dependencies: []string{ - "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AiExtension", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EnvoyContainer", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.IstioIntegration", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Pod", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ProxyDeployment", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SdsContainer", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Service", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ServiceAccount", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StatsConfig"}, + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AiExtension", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EnvoyContainer", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.InferenceExtension", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.IstioIntegration", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Pod", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ProxyDeployment", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SdsContainer", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Service", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ServiceAccount", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StatsConfig"}, } }