From 3edb71e617b289a5e6cd339f7bd097b61d0088d6 Mon Sep 17 00:00:00 2001 From: unique-jakub Date: Fri, 1 Aug 2025 06:51:07 +0200 Subject: [PATCH] allow helm hooks for migrations job (#13174) --- deploy/charts/litellm-helm/README.md | 16 ++++++++++++++++ .../litellm-helm/templates/migrations-job.yaml | 9 ++++++++- deploy/charts/litellm-helm/values.yaml | 7 +++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/deploy/charts/litellm-helm/README.md b/deploy/charts/litellm-helm/README.md index 31bda3f7d7..cef2b8d162 100644 --- a/deploy/charts/litellm-helm/README.md +++ b/deploy/charts/litellm-helm/README.md @@ -110,6 +110,22 @@ data: Source: [GitHub Gist from troyharvey](https://gist.github.com/troyharvey/4506472732157221e04c6b15e3b3f094) +### Migration Job Settings + +The migration job supports both ArgoCD and Helm hooks to ensure database migrations run at the appropriate time during deployments. + +| Name | Description | Value | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | +| `migrationJob.enabled` | Enable or disable the schema migration Job | `true` | +| `migrationJob.backoffLimit` | Backoff limit for Job restarts | `4` | +| `migrationJob.ttlSecondsAfterFinished` | TTL for completed migration jobs | `120` | +| `migrationJob.annotations` | Additional annotations for the migration job pod | `{}` | +| `migrationJob.extraContainers` | Additional containers to run alongside the migration job | `[]` | +| `migrationJob.hooks.argocd.enabled` | Enable ArgoCD hooks for the migration job (uses PreSync hook with BeforeHookCreation delete policy) | `true` | +| `migrationJob.hooks.helm.enabled` | Enable Helm hooks for the migration job (uses pre-install,pre-upgrade hooks with before-hook-creation delete policy) | `false` | +| `migrationJob.hooks.helm.weight` | Helm hook execution order (lower weights executed first). Optional - defaults to "1" if not specified. | N/A | + + ## Accessing the Admin UI When browsing to the URL published per the settings in `ingress.*`, you will be prompted for **Admin Configuration**. The **Proxy Endpoint** is the internal diff --git a/deploy/charts/litellm-helm/templates/migrations-job.yaml b/deploy/charts/litellm-helm/templates/migrations-job.yaml index 4917678831..143e62fceb 100644 --- a/deploy/charts/litellm-helm/templates/migrations-job.yaml +++ b/deploy/charts/litellm-helm/templates/migrations-job.yaml @@ -5,8 +5,15 @@ kind: Job metadata: name: {{ include "litellm.fullname" . }}-migrations annotations: + {{- if .Values.migrationJob.hooks.argocd.enabled }} argocd.argoproj.io/hook: PreSync - argocd.argoproj.io/hook-delete-policy: BeforeHookCreation # delete old migration on a new deploy in case the migration needs to make updates + argocd.argoproj.io/hook-delete-policy: BeforeHookCreation + {{- end }} + {{- if .Values.migrationJob.hooks.helm.enabled }} + helm.sh/hook: "pre-install,pre-upgrade" + helm.sh/hook-delete-policy: "before-hook-creation" + helm.sh/hook-weight: {{ .Values.migrationJob.hooks.helm.weight | default "1" | quote }} + {{- end }} checksum/config: {{ toYaml .Values | sha256sum }} spec: template: diff --git a/deploy/charts/litellm-helm/values.yaml b/deploy/charts/litellm-helm/values.yaml index 0c00d2325a..5324f6de76 100644 --- a/deploy/charts/litellm-helm/values.yaml +++ b/deploy/charts/litellm-helm/values.yaml @@ -201,6 +201,13 @@ migrationJob: annotations: {} ttlSecondsAfterFinished: 120 extraContainers: [] + + # Hook configuration + hooks: + argocd: + enabled: true + helm: + enabled: false # Additional environment variables to be added to the deployment as a map of key-value pairs envVars: {