Skip to content

Commit

Permalink
kserve canary routemap template
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kalantar <kalantar@us.ibm.com>
  • Loading branch information
kalantar committed Oct 9, 2023
1 parent 36aed89 commit 1332193
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 4 deletions.
87 changes: 87 additions & 0 deletions charts/release/templates/_kserve.canary.routemap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{{- define "env.kserve.canary.routemap" }}

{{- $APP_NAME := (include "application.name" .) }}
{{- $APP_NAMESPACE := (include "application.namespace" .) }}
{{- $versions := include "normalize.versions" . | mustFromJson }}

apiVersion: v1
kind: ConfigMap
{{ template "routemap.metadata" . }}
data:
strSpec: |
versions:
{{- range $i, $v := $versions }}
- resources:
- gvrShort: isvc
name: {{ $v.VERSION_NAME }}
namespace: {{ $v.VERSION_NAMESPACE }}
weight: {{ $v.weight }}
{{- end }} {{- /* range $i, $v := .Values.application.versions */}}
routingTemplates:
{{ .Values.application.strategy }}:
gvrShort: vs
template: |
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: {{ $APP_NAME }}
namespace: {{ $APP_NAMESPACE }}
spec:
gateways:
- knative-serving/knative-ingress-gateway
- knative-serving/knative-local-gateway
- mesh
hosts:
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc.cluster.local
http:
# non-primary versions
{{- /* For candidate versions, ensure mm-model header is required in all matches */}}
{{- range $i, $v := (rest $versions) }}
{{- /* continue only if candidate is ready (weight > 0) */}}
{{ `{{- if gt (index .Weights ` }}{{ print (add1 $i) }}{{ `) 0 }}`}}
- name: {{ (index $versions (add1 $i)).VERSION_NAME }}
match:
{{- /* A match may have several ORd clauses */}}
{{- range $j, $m := $v.match }}
{{- /* include any other header requirements */}}
{{- if (hasKey $m "headers") }}
- headers:
{{ toYaml (pick $m "headers").headers | indent 18 }}
{{- end }}
{{- /* include any other (non-header) requirements */}}
{{- if gt (omit $m "headers" | keys | len) 0 }}
{{ toYaml (omit $m "headers") | indent 16 }}
{{- end }}
{{- end }}
rewrite:
uri: /v2/models/{{ (index $versions (add1 $i)).VERSION_NAME }}/infer
route:
- destination:
host: knative-local-gateway.istio-system.svc.cluster.local
headers:
request:
set:
Host: {{ (index $versions (add1 $i)).VERSION_NAME }}-{{ template "kserve.host" $ }}
response:
add:
app-version: "{{ (index $versions (add1 $i)).VERSION_NAME }}"
{{ `{{- end }}`}}
{{- end }}
# primary version (default)
- name: {{ (index $versions 0).VERSION_NAME }}
rewrite:
uri: /v2/models/{{ (index $versions 0).VERSION_NAME }}/infer
route:
- destination:
host: knative-local-gateway.istio-system.svc.cluster.local
headers:
request:
set:
Host: {{ (index $versions 0).VERSION_NAME }}-{{ template "kserve.host" $ }}
response:
add:
app-version: "{{ (index $versions 0).VERSION_NAME }}"

{{- end }} {{- /* define "env.kserve.canary.routemap" */}}
1 change: 0 additions & 1 deletion charts/release/templates/_kserve.version.isvc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{{- /* compute basic metadata */}}
{{- $metadata := include "application.version.metadata" . | mustFromJson }}
{{- /* add annotation serving.kserve.io/deploymentMode */}}
{{- $metadata := set $metadata "annotations" (merge $metadata.annotations (dict "serving.kserve.io/deploymentMode" "ModelMesh")) }}

{{- /* define InferenceServcie */}}
apiVersion: serving.kserve.io/v1beta1
Expand Down
5 changes: 2 additions & 3 deletions charts/release/templates/_mm-istio.canary.routemap.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ data:
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc
- {{ $APP_NAME }}.{{ $APP_NAMESPACE }}.svc.cluster.local
http:
# non-primary model versions

# non-primary versions
{{- /* For candidate versions, ensure mm-model header is required in all matches */}}
{{- range $i, $v := (rest $versions) }}
{{- /* continue only if candidate is ready (ie, weight > 0) */}}
Expand Down Expand Up @@ -67,7 +66,7 @@ data:
app-version: {{ (index $versions (add1 $i)).VERSION_NAME }}
{{ `{{- end }}`}}
{{- end }}
# primary model version (default)
# primary version (default)
- name: {{ (index $versions 0).VERSION_NAME }}
route:
- destination:
Expand Down

0 comments on commit 1332193

Please sign in to comment.