diff --git a/charts/release/templates/_deployment-istio.version.deployment.tpl b/charts/release/templates/_deployment-istio.version.deployment.tpl index aaeb9ae96..5e9437105 100644 --- a/charts/release/templates/_deployment-istio.version.deployment.tpl +++ b/charts/release/templates/_deployment-istio.version.deployment.tpl @@ -1,17 +1,7 @@ {{- define "env.deployment-istio.version.deployment" }} -{{- /* compute labels */}} -{{- $labels := include "application.version.labels" . | mustFromJson }} - -{{- /* compute annotations */}} -{{- $annotations := include "application.version.annotations" . | mustFromJson }} - -{{- /* compose into metadata */}} -{{- $metadata := (dict) }} -{{- $metadata := set $metadata "name" .VERSION_NAME }} -{{- $metadata := set $metadata "namespace" .VERSION_NAMESPACE }} -{{- $metadata := set $metadata "labels" $labels }} -{{- $metadata := set $metadata "annotations" $annotations }} +{{- /* compute basic metadata */}} +{{- $metadata := include "application.version.metadata" . | mustFromJson }} apiVersion: apps/v1 kind: Deployment diff --git a/charts/release/templates/_deployment-istio.version.service.tpl b/charts/release/templates/_deployment-istio.version.service.tpl index 2f393579b..30b3b1790 100644 --- a/charts/release/templates/_deployment-istio.version.service.tpl +++ b/charts/release/templates/_deployment-istio.version.service.tpl @@ -1,17 +1,7 @@ {{- define "env.deployment-istio.version.service" }} -{{- /* compute labels */}} -{{- $labels := include "application.version.labels" . | mustFromJson }} - -{{- /* compute annotations */}} -{{- $annotations := include "application.version.annotations" . | mustFromJson }} - -{{- /* compose into metadata */}} -{{- $metadata := (dict) }} -{{- $metadata := set $metadata "name" .VERSION_NAME }} -{{- $metadata := set $metadata "namespace" .VERSION_NAMESPACE }} -{{- $metadata := set $metadata "labels" $labels }} -{{- $metadata := set $metadata "annotations" $annotations }} +{{- /* compute basic metadata */}} +{{- $metadata := include "application.version.metadata" . | mustFromJson }} apiVersion: v1 kind: Service diff --git a/charts/release/templates/_helpers.tpl b/charts/release/templates/_helpers.tpl index 3a5a776d2..ef3f39760 100644 --- a/charts/release/templates/_helpers.tpl +++ b/charts/release/templates/_helpers.tpl @@ -1,8 +1,3 @@ -{{- define "release.labels" -}} - labels: - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} -{{- end -}} - {{- define "application.name" -}} {{- if (and .Values.application .Values.application.metadata .Values.application.metadata.name) -}} {{ .Values.application.metadata.name -}} @@ -43,6 +38,19 @@ {{- mustToJson $annotations }} {{- end -}} {{- /* define "application.version.annotations" */}} +{{- define "application.version.metadata" -}} +{{- $labels := (include "application.version.labels" . | mustFromJson) }} +{{- $annotations := (include "application.version.annotations" . | mustFromJson) }} +{{- /* compose into metadata */}} +{{- $metadata := (dict) }} +{{- $metadata := set $metadata "name" .VERSION_NAME }} +{{- $metadata := set $metadata "namespace" .VERSION_NAMESPACE }} +{{- $metadata := set $metadata "labels" $labels }} +{{- $metadata := set $metadata "annotations" $annotations }} +{{- /* return as JSON */}} +{{- mustToJson $metadata }} +{{- end -}} {{- /* define "application.version.metadata" */}} + {{- define "routemap.metadata" }} metadata: name: {{ template "application.name" . }}-routemap @@ -60,14 +68,8 @@ metadata: {{- $metadata := merge $metadata .Values.application.metadata }} {{- end }} {{- /* if .Values.application.metadata */}} - {{- $APP_NAME := .Release.Name }} - {{- if $metadata.name }} - {{- $APP_NAME := $metadata.name }} - {{- end }} - {{- $APP_NAMESPACE := .Release.Namespace }} - {{- if $metadata.namespace }} - {{- $APP_NAMESPACE := $metadata.namespace }} - {{- end }} + {{- $APP_NAME := (include "application.name" .) }} + {{- $APP_NAMESPACE := (include "application.namespace" .) }} {{- $defaultMatch := ternary (list (dict "headers" (dict "traffic" (dict "exact" "test")))) (dict) (eq .Values.application.strategy "canary") }} @@ -101,10 +103,7 @@ metadata: {{- end }} {{- /* define "normalize.versions" */}} {{- define "kserve.host" -}} -{{- $APP_NAMESPACE := .Release.Namespace -}} -{{- if (and .Values.application .Values.application.metadata) -}} -{{- $APP_NAMESPACE := .Values.application.metadata.namespace -}} -{{- end -}} +{{- $APP_NAMESPACE := (include "application.namespace" .) }} {{- if eq "kserve-0.10" .Values.environment -}} predictor-default.{{ $APP_NAMESPACE }}.svc.cluster.local {{- else }} {{- /* kserve-0.11 or kserve */ -}} diff --git a/charts/release/templates/_kserve.version.isvc.tpl b/charts/release/templates/_kserve.version.isvc.tpl index 73e186473..a9df5fb8b 100644 --- a/charts/release/templates/_kserve.version.isvc.tpl +++ b/charts/release/templates/_kserve.version.isvc.tpl @@ -1,18 +1,9 @@ {{- define "env.kserve.version.isvc" }} -{{- /* compute labels */}} -{{- $labels := include "application.version.labels" . | mustFromJson }} - -{{- /* compute annotations */}} -{{- $annotations := include "application.version.annotations" . | mustFromJson }} -{{- $annotations := merge (dict "serving.kserve.io/deploymentMode" "ModelMesh") $annotations }} - -{{- /* compose into metadata */}} -{{- $metadata := (dict) }} -{{- $metadata := set $metadata "name" .VERSION_NAME }} -{{- $metadata := set $metadata "namespace" .VERSION_NAMESPACE }} -{{- $metadata := set $metadata "labels" $labels }} -{{- $metadata := set $metadata "annotations" $annotations }} +{{- /* 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 diff --git a/charts/release/templates/_mm-istio.version.isvc.tpl b/charts/release/templates/_mm-istio.version.isvc.tpl index daa0e08ae..2ad390347 100644 --- a/charts/release/templates/_mm-istio.version.isvc.tpl +++ b/charts/release/templates/_mm-istio.version.isvc.tpl @@ -1,18 +1,9 @@ {{- define "env.mm-istio.version.isvc" }} -{{- /* compute labels */}} -{{- $labels := include "application.version.labels" . | mustFromJson }} - -{{- /* compute annotations */}} -{{- $annotations := include "application.version.annotations" . | mustFromJson }} -{{- $annotations := merge (dict "serving.kserve.io/deploymentMode" "ModelMesh") $annotations }} - -{{- /* compose into metadata */}} -{{- $metadata := (dict) }} -{{- $metadata := set $metadata "name" .VERSION_NAME }} -{{- $metadata := set $metadata "namespace" .VERSION_NAMESPACE }} -{{- $metadata := set $metadata "labels" $labels }} -{{- $metadata := set $metadata "annotations" $annotations }} +{{- /* 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