Skip to content

Commit

Permalink
Add ability to deploy multiple inference-service services (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhudson authored Oct 10, 2024
1 parent afe564e commit d839dca
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 154 deletions.
2 changes: 2 additions & 0 deletions .github/actions/argocd-update/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ runs:
yq -i '(.spec.source.helm.parameters.[] | select(.name == "pod-init.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-operator.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "pod-init.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-operator-euc1.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "inferenceGateway.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-ai.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "inferenceService.default.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-ai.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "controller.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-operator-gke-usc1.yaml
yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-ai.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-ai-events-reporter.yaml
Expand Down Expand Up @@ -103,6 +104,7 @@ runs:
yq -i '(.spec.source.helm.parameters.[] | select(.name == "pod-init.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-operator-usw2.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "pod-init.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-operator-gke-usc1.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "inferenceGateway.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-ai.yaml
yq -i '(.spec.source.helm.parameters.[] | select(.name == "inferenceService.default.image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-ai.yaml
yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-ai.yaml
- name: Git commit and push to remote
Expand Down
9 changes: 5 additions & 4 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.github/** @nhudson @ianstanton @shahadarsh
.github/** @nhudson @ianstanton @shahadarsh @vrmiguel
charts/** @nhudson @ianstanton @shahadarsh
tembo-operator/** @nhudson @ianstanton @ChuckHend
conductor/** @nhudson @ianstanton @ChuckHend
dataplane-webserver/** @nhudson @ianstanton @vrmiguel
tembo-operator/** @nhudson @ianstanton @ChuckHend @vrmiguel
conductor/** @nhudson @ianstanton @ChuckHend @vrmiguel
tembo-pod-init/** @nhudson @ianstanton
tembo-cli/** @shahadarsh @vrmiguel @DarrenBaldwin07 @joshuajerin
tembo-py/** @chuckhend
tembo-stacks/** @chuckhend @jasonmp85
inference-gateway/** @chuckhend @jasonmp85
inference-gateway/** @chuckhend @jasonmp85
2 changes: 1 addition & 1 deletion charts/tembo-ai/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.3.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
7 changes: 7 additions & 0 deletions charts/tembo-ai/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Expand the name of the chart.
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Define the namespace to use across the Helm chart
*/}}
{{- define "tembo-ai.namespace" -}}
{{- default .Release.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).
Expand Down
21 changes: 20 additions & 1 deletion charts/tembo-ai/templates/inference-service/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Inference service specific labels
*/}}
{{- define "tembo-ai.inferenceService.labels" -}}
app.kubernetes.io/component: inference-service
{{ include "tembo-ai.labels" . }}
{{- end }}

Expand All @@ -20,3 +19,23 @@ Create the name of the inference-service service account to use
{{- define "tembo-ai.inferenceService.serviceAccountName" -}}
{{- include "tembo-ai.fullname" . }}-service
{{- end }}

{{/*
Deepmerge the inference-service default configs and the services sepecific configs
*/}}
{{- define "tembo-ai.inferenceService.deepMerge" -}}
{{- $result := deepCopy (index . 0) -}}
{{- range $key, $value := index . 1 -}}
{{- if kindIs "map" $value -}}
{{- if hasKey $result $key -}}
{{- $newValue := fromYaml (include "tembo-ai.inferenceService.deepMerge" (list (get $result $key) $value)) -}}
{{- $_ := set $result $key $newValue -}}
{{- else -}}
{{- $_ := set $result $key $value -}}
{{- end -}}
{{- else -}}
{{- $_ := set $result $key $value -}}
{{- end -}}
{{- end -}}
{{- $result | toYaml -}}
{{- end -}}
26 changes: 17 additions & 9 deletions charts/tembo-ai/templates/inference-service/external-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
{{- if .Values.inferenceService.externalSecrets.secretName -}}
{{- if .Values.inferenceService.services }}
{{- $defaults := .Values.inferenceService.defaults }}
{{- range $serviceName, $serviceConfig := .Values.inferenceService.services }}
{{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.deepMerge" (list $defaults $serviceConfig)) }}
{{- if and (default false $mergedConfig.enabled) $mergedConfig.externalSecrets.secretName }}
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: {{ include "tembo-ai.fullname" . }}-service
namespace: {{ .Release.Namespace }}
name: {{ include "tembo-ai.fullname" $ }}-{{ $serviceName }}
namespace: {{ include "tembo-ai.namespace" $ }}
labels:
{{- include "tembo-ai.inferenceService.labels" . | nindent 4 }}
{{- include "tembo-ai.inferenceService.labels" $ | nindent 4 }}
app.kubernetes.io/component: {{ $serviceName }}
spec:
refreshInterval: {{ .Values.inferenceService.externalSecrets.refreshInterval }}
refreshInterval: {{ $mergedConfig.externalSecrets.refreshInterval }}
secretStoreRef:
name: {{ .Values.inferenceService.externalSecrets.parameterStore.name }}
kind: {{ .Values.inferenceService.externalSecrets.parameterStore.kind }}
name: {{ $mergedConfig.externalSecrets.parameterStore.name }}
kind: {{ $mergedConfig.externalSecrets.parameterStore.kind }}
target:
creationPolicy: 'Owner'
name: {{ .Values.inferenceService.externalSecrets.secretName }}
name: {{ $mergedConfig.externalSecrets.secretName }}
dataFrom:
- find:
name:
regexp: {{ .Values.inferenceService.externalSecrets.secretRegex }}
regexp: {{ $mergedConfig.externalSecrets.secretRegex }}
{{- end }}
{{- end }}
{{- end }}
31 changes: 23 additions & 8 deletions charts/tembo-ai/templates/inference-service/pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
{{- if .Values.inferenceService.podMonitor.enabled -}}
{{- if .Values.inferenceService.services }}
{{- $defaults := .Values.inferenceService.defaults }}
{{- $releaseName := default "release-name" .Release.Name }}
{{- range $serviceName, $serviceConfig := .Values.inferenceService.services }}
{{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.deepMerge" (list $defaults $serviceConfig)) }}
{{- if and (default false $mergedConfig.enabled) (default false $mergedConfig.podMonitor.enabled) }}
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "tembo-ai.fullname" . }}-service
namespace: {{ .Release.Namespace }}
name: {{ include "tembo-ai.fullname" $ }}-{{ $serviceName }}
namespace: {{ include "tembo-ai.namespace" $ }}
labels:
{{- include "tembo-ai.inferenceService.labels" . | nindent 4 }}
{{- include "tembo-ai.inferenceService.labels" $ | nindent 4 }}
app.kubernetes.io/component: {{ $serviceName }}
spec:
podMetricsEndpoints:
- path: {{ .Values.inferenceService.podMonitor.path }}
port: {{ .Values.inferenceService.podMonitor.portName }}
- port: {{ $mergedConfig.podMonitor.portName }}
path: {{ $mergedConfig.podMonitor.path }}
{{- with $mergedConfig.podMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with $mergedConfig.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
- {{ include "tembo-ai.namespace" $ }}
selector:
matchLabels:
{{- include "tembo-ai.inferenceService.selectorLabels" . | nindent 6 }}
{{- include "tembo-ai.inferenceService.selectorLabels" $ | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 17 additions & 5 deletions charts/tembo-ai/templates/inference-service/service.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
{{- if .Values.inferenceService.services }}
{{- $defaults := .Values.inferenceService.defaults }}
{{- range $serviceName, $serviceConfig := .Values.inferenceService.services }}
{{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.deepMerge" (list $defaults $serviceConfig)) }}
{{- if and (default false $mergedConfig.enabled) (default true $mergedConfig.service.enabled) }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "tembo-ai.fullname" . }}-service
name: {{ include "tembo-ai.fullname" $ }}-{{ $serviceName }}
namespace: {{ include "tembo-ai.namespace" $ }}
labels:
{{- include "tembo-ai.inferenceService.labels" . | nindent 4 }}
{{- include "tembo-ai.inferenceService.labels" $ | nindent 4 }}
app.kubernetes.io/component: {{ $serviceName }}
spec:
clusterIP: None
type: {{ .Values.inferenceService.service.type }}
type: {{ $mergedConfig.service.type | default "ClusterIP" }}
ports:
- port: {{ .Values.inferenceService.service.port }}
- port: {{ $mergedConfig.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "tembo-ai.inferenceService.selectorLabels" . | nindent 4 }}
{{- include "tembo-ai.inferenceService.selectorLabels" $ | nindent 4 }}
app.kubernetes.io/component: {{ $serviceName }}
{{- end }}
{{- end }}
{{- end }}
27 changes: 24 additions & 3 deletions charts/tembo-ai/templates/inference-service/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
{{- if .Values.inferenceService.services }}
{{- $defaults := .Values.inferenceService.defaults }}
{{- range $serviceName, $serviceConfig := .Values.inferenceService.services }}
{{- $mergedConfig := fromYaml (include "tembo-ai.inferenceService.deepMerge" (list $defaults $serviceConfig)) }}
{{- if and (default false $mergedConfig.enabled) (default true $mergedConfig.serviceAccount.create) }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "tembo-ai.inferenceService.serviceAccountName" . }}
name: {{ include "tembo-ai.fullname" $ }}-{{ $serviceName }}
namespace: {{ include "tembo-ai.namespace" $ }}
labels:
{{- include "tembo-ai.inferenceService.labels" . | nindent 4 }}
{{- with .Values.inferenceService.serviceAccount.annotations }}
{{- include "tembo-ai.inferenceService.labels" $ | nindent 4 }}
app.kubernetes.io/component: {{ $serviceName }}
{{- with $mergedConfig.serviceAccount.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $mergedConfig.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if $mergedConfig.serviceAccount.imagePullSecrets }}
imagePullSecrets:
{{- toYaml $mergedConfig.serviceAccount.imagePullSecrets | nindent 2 }}
{{- end }}
{{- if hasKey $mergedConfig.serviceAccount "automountServiceAccountToken" }}
automountServiceAccountToken: {{ $mergedConfig.serviceAccount.automountServiceAccountToken }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit d839dca

Please sign in to comment.