From 2d18dc3249718224bafb04df63c2cda8b579a820 Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Wed, 2 Oct 2024 17:44:33 -0500 Subject: [PATCH] code cleanup --- charts/tembo-ai/templates/_helpers.tpl | 9 +++++- .../templates/inference-service/_helpers.tpl | 31 +------------------ .../inference-service/external-secret.yaml | 2 +- .../inference-service/pod-monitor.yaml | 2 +- .../templates/inference-service/service.yaml | 2 +- .../inference-service/serviceaccount.yaml | 2 +- .../inference-service/statefulset.yaml | 5 ++- 7 files changed, 15 insertions(+), 38 deletions(-) diff --git a/charts/tembo-ai/templates/_helpers.tpl b/charts/tembo-ai/templates/_helpers.tpl index 13bc2f7ed..47f36fa83 100644 --- a/charts/tembo-ai/templates/_helpers.tpl +++ b/charts/tembo-ai/templates/_helpers.tpl @@ -2,9 +2,16 @@ Expand the name of the chart. */}} {{- define "tembo-ai.name" -}} -{{- default $.Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} +{{/* +Define the namespace to use across the inference-service templates +*/}} +{{- define "tembo-ai.namespace" -}} +{{- default .Release.Namespace .Values.namespace }} +{{- end -}} + {{/* Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). diff --git a/charts/tembo-ai/templates/inference-service/_helpers.tpl b/charts/tembo-ai/templates/inference-service/_helpers.tpl index 17ffac23e..4e9c36839 100644 --- a/charts/tembo-ai/templates/inference-service/_helpers.tpl +++ b/charts/tembo-ai/templates/inference-service/_helpers.tpl @@ -20,39 +20,10 @@ Create the name of the inference-service service account to use {{- include "tembo-ai.fullname" . }}-service {{- end }} -{{/* -Define the namespace to use across the inference-service templates -*/}} -{{- define "tembo-ai.namespace" -}} -{{- default .Release.Namespace .Values.namespace }} -{{- end -}} - -{{/* -Define the image configuration with override options -*/}} -{{- define "tembo-ai.inferenceService.imageConfig" -}} -{{- $defaultConfig := .defaultConfig -}} -{{- $serviceConfig := .serviceConfig -}} -{{- $result := dict -}} -{{- range $key, $value := $defaultConfig -}} - {{- if hasKey $serviceConfig $key -}} - {{- $_ := set $result $key (index $serviceConfig $key) -}} - {{- else -}} - {{- $_ := set $result $key $value -}} - {{- end -}} -{{- end -}} -{{- range $key, $value := $serviceConfig -}} - {{- if not (hasKey $result $key) -}} - {{- $_ := set $result $key $value -}} - {{- end -}} -{{- end -}} -{{- $result | toYaml -}} -{{- end -}} - {{/* Merge configurations with priority to service-specific configs, handling nested structures */}} -{{- define "tembo-ai.mergeConfigs" -}} +{{- define "tembo-ai.inferenceService.mergeConfigs" -}} {{- $result := dict -}} {{- range $key, $value := .defaults -}} {{- if kindIs "map" $value -}} diff --git a/charts/tembo-ai/templates/inference-service/external-secret.yaml b/charts/tembo-ai/templates/inference-service/external-secret.yaml index c16175185..457263ffd 100644 --- a/charts/tembo-ai/templates/inference-service/external-secret.yaml +++ b/charts/tembo-ai/templates/inference-service/external-secret.yaml @@ -1,7 +1,7 @@ {{- if .Values.inferenceService.services }} {{- $defaults := .Values.inferenceService.defaults }} {{- range $serviceName, $serviceConfig := .Values.inferenceService.services }} - {{- $mergedConfig := fromYaml (include "tembo-ai.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} + {{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} {{- if and (default false $mergedConfig.enabled) $mergedConfig.externalSecrets.secretName }} --- apiVersion: external-secrets.io/v1beta1 diff --git a/charts/tembo-ai/templates/inference-service/pod-monitor.yaml b/charts/tembo-ai/templates/inference-service/pod-monitor.yaml index 5094ade23..53f798b81 100644 --- a/charts/tembo-ai/templates/inference-service/pod-monitor.yaml +++ b/charts/tembo-ai/templates/inference-service/pod-monitor.yaml @@ -2,7 +2,7 @@ {{- $defaults := .Values.inferenceService.defaults }} {{- $releaseName := default "release-name" .Release.Name }} {{- range $serviceName, $serviceConfig := .Values.inferenceService.services }} - {{- $mergedConfig := fromYaml (include "tembo-ai.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} + {{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} {{- if and (default false $mergedConfig.enabled) (default false $mergedConfig.podMonitor.enabled) }} --- apiVersion: monitoring.coreos.com/v1 diff --git a/charts/tembo-ai/templates/inference-service/service.yaml b/charts/tembo-ai/templates/inference-service/service.yaml index 5a6c8a4dc..b455649e8 100644 --- a/charts/tembo-ai/templates/inference-service/service.yaml +++ b/charts/tembo-ai/templates/inference-service/service.yaml @@ -1,7 +1,7 @@ {{- if .Values.inferenceService.services }} {{- $defaults := .Values.inferenceService.defaults }} {{- range $serviceName, $serviceConfig := .Values.inferenceService.services }} - {{- $mergedConfig := fromYaml (include "tembo-ai.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} + {{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} {{- if and (default false $mergedConfig.enabled) (default true $mergedConfig.service.enabled) }} --- apiVersion: v1 diff --git a/charts/tembo-ai/templates/inference-service/serviceaccount.yaml b/charts/tembo-ai/templates/inference-service/serviceaccount.yaml index 71567d941..af04789c7 100644 --- a/charts/tembo-ai/templates/inference-service/serviceaccount.yaml +++ b/charts/tembo-ai/templates/inference-service/serviceaccount.yaml @@ -1,7 +1,7 @@ {{- if .Values.inferenceService.services }} {{- $defaults := .Values.inferenceService.defaults }} {{- range $serviceName, $serviceConfig := .Values.inferenceService.services }} - {{- $mergedConfig := fromYaml (include "tembo-ai.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} + {{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} {{- if and (default false $mergedConfig.enabled) (default true $mergedConfig.serviceAccount.create) }} --- apiVersion: v1 diff --git a/charts/tembo-ai/templates/inference-service/statefulset.yaml b/charts/tembo-ai/templates/inference-service/statefulset.yaml index 21e9bf077..5b13f167d 100644 --- a/charts/tembo-ai/templates/inference-service/statefulset.yaml +++ b/charts/tembo-ai/templates/inference-service/statefulset.yaml @@ -1,8 +1,7 @@ {{- if .Values.inferenceService.services }} {{- $defaults := .Values.inferenceService.defaults }} {{- range $serviceName, $serviceConfig := .Values.inferenceService.services }} - {{- $mergedConfig := fromYaml (include "tembo-ai.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} - {{- $imageConfig := fromYaml (include "tembo-ai.inferenceService.imageConfig" (dict "defaultConfig" $.Values.inferenceService.defaults.image "serviceConfig" $serviceConfig.image)) }} + {{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.mergeConfigs" (dict "defaults" $defaults "service" $serviceConfig)) }} {{- if (default false $mergedConfig.enabled) }} --- apiVersion: apps/v1 @@ -41,7 +40,7 @@ spec: - name: inference-service securityContext: {{- toYaml $mergedConfig.securityContext | nindent 12 }} - image: "{{ $imageConfig.repository }}:{{ $imageConfig.tag }}" + image: "{{ $mergedConfig.image.repository }}:{{ $mergedConfig.image.tag }}" imagePullPolicy: {{ $mergedConfig.image.pullPolicy }} ports: - name: http