Skip to content

Commit ba1cb49

Browse files
committed
local fix
1 parent fbd3ef5 commit ba1cb49

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
k8s.io/klog/v2 v2.130.1
2020
k8s.io/utils v0.0.0-20241210054802-24370beab758
2121
sigs.k8s.io/controller-runtime v0.20.3
22+
sigs.k8s.io/gateway-api v1.2.1
2223
sigs.k8s.io/lws v0.5.1
2324
sigs.k8s.io/structured-merge-diff/v4 v4.7.0
2425
sigs.k8s.io/yaml v1.4.0
@@ -113,6 +114,5 @@ require (
113114
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect
114115
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect
115116
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.1 // indirect
116-
sigs.k8s.io/gateway-api v1.2.1 // indirect
117117
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
118118
)

pkg/controller/inference/gateway.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
"k8s.io/apimachinery/pkg/types"
2525
"sigs.k8s.io/controller-runtime/pkg/client"
26+
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
2627
)
2728

2829
// gateway related utils: currently only support envoy ai gateway
@@ -54,24 +55,23 @@ func IsAIGatewayRouteExist(ctx context.Context, client client.Client) (bool, err
5455
// name: qwen2-0--5b-lb # model name
5556
// kind: Service
5657
// port: 8080
57-
func CreateAIServiceBackend(ctx context.Context, client client.Client, backendRefName, namespace string, port int, schemaName string) error {
58-
if schemaName == "" {
59-
schemaName = "OpenAI"
60-
}
58+
func CreateAIServiceBackend(ctx context.Context, client client.Client, backendRefName, namespace string, port int) error {
59+
kind := gwapiv1.Kind("Service")
60+
portName := gwapiv1.PortNumber(port)
6161
// create the AIServiceBackend
6262
backend := &aigv1a1.AIServiceBackend{
6363
ObjectMeta: metav1.ObjectMeta{
6464
Name: backendRefName,
6565
Namespace: namespace,
6666
},
6767
Spec: aigv1a1.AIServiceBackendSpec{
68-
Schema: aigv1a1.AIServiceBackendSchema{
69-
Name: schemaName,
68+
APISchema: aigv1a1.VersionedAPISchema{
69+
Name: aigv1a1.APISchemaOpenAI,
7070
},
71-
BackendRef: aigv1a1.AIServiceBackendRef{
72-
Name: backendRefName,
73-
Kind: "Service",
74-
Port: port,
71+
BackendRef: gwapiv1.BackendObjectReference{
72+
Name: gwapiv1.ObjectName(backendRefName),
73+
Kind: &kind,
74+
Port: &portName,
7575
},
7676
},
7777
}
@@ -108,20 +108,21 @@ func UpdateAIGatewayRoute(ctx context.Context, client client.Client, backendRefN
108108
return nil
109109
}
110110
}
111+
exact := gwapiv1.HeaderMatchExact
111112
// if the rule does not exist, append it to the spec.rules list
112113
rule := aigv1a1.AIGatewayRouteRule{
113-
Matches: []aigv1a1.AIGatewayRouteMatch{
114+
Matches: []aigv1a1.AIGatewayRouteRuleMatch{
114115
{
115-
Headers: []aigv1a1.AIGatewayRouteHeaderMatch{
116+
Headers: []gwapiv1.HTTPHeaderMatch{
116117
{
117-
Type: aigv1a1.HeaderMatchTypeExact,
118+
Type: &exact,
118119
Name: "x-ai-eg-model",
119120
Value: modelName,
120121
},
121122
},
122123
},
123124
},
124-
BackendRefs: []aigv1a1.AIGatewayRouteBackendRef{
125+
BackendRefs: []aigv1a1.AIGatewayRouteRuleBackendRef{
125126
{
126127
Name: backendRefName,
127128
},

pkg/controller/inference/playground_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (r *PlaygroundReconciler) Reconcile(ctx context.Context, req ctrl.Request)
160160
var aiServiceBackend aigv1a1.AIServiceBackend
161161
if err := r.Get(ctx, types.NamespacedName{Name: playground.Name, Namespace: playground.Namespace}, &aiServiceBackend); err != nil {
162162
if apierrors.IsNotFound(err) {
163-
err = CreateAIServiceBackend(ctx, r.Client, playground.Name, playground.Namespace, modelSource.DEFAULT_BACKEND_PORT, "")
163+
err = CreateAIServiceBackend(ctx, r.Client, playground.Name, playground.Namespace, modelSource.DEFAULT_BACKEND_PORT)
164164
if err != nil {
165165
logger.Error(err, "failed to create aiServiceBackend", "Playground", klog.KObj(playground))
166166
return ctrl.Result{}, err

pkg/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ limitations under the License.
1717
package pkg
1818

1919
const (
20-
LOADER_IMAGE = "inftyai/model-loader:v0.0.10"
20+
LOADER_IMAGE = "m.daocloud.io/docker.io/inftyai/model-loader:v0.0.10"
2121
)

0 commit comments

Comments
 (0)