diff --git a/helm/litellm/templates/_helpers.tpl b/helm/litellm/templates/_helpers.tpl index 8cb2fbf441d..2a094a5fb63 100644 --- a/helm/litellm/templates/_helpers.tpl +++ b/helm/litellm/templates/_helpers.tpl @@ -56,6 +56,9 @@ app.kubernetes.io/name: {{ include "litellm.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }} +{{- with .Values.commonLabels }} +{{ toYaml . }} +{{- end }} {{- end -}} {{/* diff --git a/helm/litellm/templates/backend/deployment.yaml b/helm/litellm/templates/backend/deployment.yaml index 7360261dab1..a94e9265940 100644 --- a/helm/litellm/templates/backend/deployment.yaml +++ b/helm/litellm/templates/backend/deployment.yaml @@ -7,7 +7,14 @@ metadata: name: {{ include "litellm.backend.fullname" . }} labels: {{- include "litellm.commonLabels" . | nindent 4 }} + {{- with .Values.backend.deploymentLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} app.kubernetes.io/component: backend + {{- with .Values.backend.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: {{- if and (not .Values.backend.hpa.enabled) (not (kindIs "invalid" .Values.backend.replicaCount)) }} replicas: {{ .Values.backend.replicaCount }} diff --git a/helm/litellm/templates/gateway/deployment.yaml b/helm/litellm/templates/gateway/deployment.yaml index b0e7f0dcebb..24c47cde0d5 100644 --- a/helm/litellm/templates/gateway/deployment.yaml +++ b/helm/litellm/templates/gateway/deployment.yaml @@ -5,7 +5,14 @@ metadata: name: {{ include "litellm.gateway.fullname" . }} labels: {{- include "litellm.commonLabels" . | nindent 4 }} + {{- with .Values.gateway.deploymentLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} app.kubernetes.io/component: gateway + {{- with .Values.gateway.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: {{- if and (not .Values.gateway.hpa.enabled) (not (kindIs "invalid" .Values.gateway.replicaCount)) }} replicas: {{ .Values.gateway.replicaCount }} diff --git a/helm/litellm/templates/migrations-job.yaml b/helm/litellm/templates/migrations-job.yaml index de1cc2b103b..9991ec2d397 100644 --- a/helm/litellm/templates/migrations-job.yaml +++ b/helm/litellm/templates/migrations-job.yaml @@ -15,8 +15,11 @@ metadata: name: {{ include "litellm.fullname" . }}-migrations labels: {{- include "litellm.commonLabels" . | nindent 4 }} + {{- with .Values.migrationJob.jobLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} app.kubernetes.io/component: migrations - {{- if or .Values.migrationJob.hooks.helm.enabled .Values.migrationJob.hooks.argocd.enabled }} + {{- if or .Values.migrationJob.hooks.helm.enabled .Values.migrationJob.hooks.argocd.enabled .Values.migrationJob.jobAnnotations }} annotations: {{- if .Values.migrationJob.hooks.helm.enabled }} helm.sh/hook: pre-install,pre-upgrade @@ -27,6 +30,9 @@ metadata: argocd.argoproj.io/hook: PreSync argocd.argoproj.io/hook-delete-policy: BeforeHookCreation {{- end }} + {{- with .Values.migrationJob.jobAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- end }} spec: backoffLimit: {{ .Values.migrationJob.backoffLimit }} diff --git a/helm/litellm/templates/ui/deployment.yaml b/helm/litellm/templates/ui/deployment.yaml index 394eea17451..8e2856ffe52 100644 --- a/helm/litellm/templates/ui/deployment.yaml +++ b/helm/litellm/templates/ui/deployment.yaml @@ -7,7 +7,14 @@ metadata: name: {{ include "litellm.ui.fullname" . }} labels: {{- include "litellm.commonLabels" . | nindent 4 }} + {{- with .Values.ui.deploymentLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} app.kubernetes.io/component: ui + {{- with .Values.ui.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: {{- if and (not .Values.ui.hpa.enabled) (not (kindIs "invalid" .Values.ui.replicaCount)) }} replicas: {{ .Values.ui.replicaCount }} diff --git a/helm/litellm/tests/deployment_volumes_tests.yaml b/helm/litellm/tests/deployment_volumes_tests.yaml index 3a64300b86c..c87101304d0 100644 --- a/helm/litellm/tests/deployment_volumes_tests.yaml +++ b/helm/litellm/tests/deployment_volumes_tests.yaml @@ -170,3 +170,60 @@ tests: value: - name: nginx-config mountPath: /etc/nginx/conf.d + + - it: gateway deployment applies commonLabels, deploymentLabels and deploymentAnnotations + template: gateway/deployment.yaml + set: + commonLabels: + team: platform + gateway.deploymentLabels: + custom/label: gateway-label + gateway.deploymentAnnotations: + custom/annotation: gateway-annotation + asserts: + - isSubset: + path: metadata.labels + content: + team: platform + custom/label: gateway-label + - equal: + path: metadata.annotations["custom/annotation"] + value: gateway-annotation + + - it: backend deployment applies commonLabels, deploymentLabels and deploymentAnnotations + template: backend/deployment.yaml + set: + commonLabels: + team: platform + backend.deploymentLabels: + custom/label: backend-label + backend.deploymentAnnotations: + custom/annotation: backend-annotation + asserts: + - isSubset: + path: metadata.labels + content: + team: platform + custom/label: backend-label + - equal: + path: metadata.annotations["custom/annotation"] + value: backend-annotation + + - it: ui deployment applies commonLabels, deploymentLabels and deploymentAnnotations + template: ui/deployment.yaml + set: + commonLabels: + team: platform + ui.deploymentLabels: + custom/label: ui-label + ui.deploymentAnnotations: + custom/annotation: ui-annotation + asserts: + - isSubset: + path: metadata.labels + content: + team: platform + custom/label: ui-label + - equal: + path: metadata.annotations["custom/annotation"] + value: ui-annotation diff --git a/helm/litellm/tests/ingress_controller_tests.yaml b/helm/litellm/tests/ingress_controller_tests.yaml index aa30db3c9c1..6ee28b3524c 100644 --- a/helm/litellm/tests/ingress_controller_tests.yaml +++ b/helm/litellm/tests/ingress_controller_tests.yaml @@ -213,3 +213,16 @@ tests: name: RELEASE-NAME-litellm-ui port: number: 3000 + + - it: includes common labels in the ingress metadata + set: + commonLabels: + team: platform + foo: bar + ingress.enabled: true + asserts: + - isSubset: + path: metadata.labels + content: + team: platform + foo: bar \ No newline at end of file diff --git a/helm/litellm/tests/migration_job_tests.yaml b/helm/litellm/tests/migration_job_tests.yaml index 2ebb1b44926..157a0113202 100644 --- a/helm/litellm/tests/migration_job_tests.yaml +++ b/helm/litellm/tests/migration_job_tests.yaml @@ -254,3 +254,35 @@ tests: path: spec.template.spec.nodeSelector - isNull: path: spec.template.spec.tolerations + + - it: applies commonLabels, jobLabels and jobAnnotations to the Job + set: + commonLabels: + team: platform + migrationJob.jobLabels: + custom/label: job-label + migrationJob.jobAnnotations: + custom/annotation: job-annotation + asserts: + - isSubset: + path: metadata.labels + content: + team: platform + custom/label: job-label + app.kubernetes.io/component: migrations + - equal: + path: metadata.annotations["custom/annotation"] + value: job-annotation + + - it: keeps hook annotations alongside custom jobAnnotations + set: + migrationJob.hooks.helm.enabled: true + migrationJob.jobAnnotations: + custom/annotation: job-annotation + asserts: + - equal: + path: metadata.annotations["custom/annotation"] + value: job-annotation + - equal: + path: metadata.annotations["helm.sh/hook"] + value: pre-install,pre-upgrade diff --git a/helm/litellm/values.yaml b/helm/litellm/values.yaml index aa6ee7a6056..1892329d2c0 100644 --- a/helm/litellm/values.yaml +++ b/helm/litellm/values.yaml @@ -2,7 +2,7 @@ nameOverride: "" fullnameOverride: "" - +commonLabels: {} imagePullSecrets: [] # Optional Ingress wiring the three component Services behind a single L7 @@ -150,6 +150,10 @@ migrationJob: # pod. Same shape as gateway.podSecurityContext / gateway.securityContext. podSecurityContext: {} securityContext: {} + # Extra labels on the Job itself. + jobLabels: {} + # Extra annotations on the Job itself. + jobAnnotations: {} # Extra pod labels on the Job pod, merged into the chart's common labels. podLabels: {} # Additional volumes on the Job pod and volumeMounts on its container, e.g. @@ -465,6 +469,10 @@ gateway: enabled: false minAvailable: "" maxUnavailable: "" + # Extra annotations on the gateway Deployment itself. + deploymentAnnotations: {} + # Extra labels on the gateway Deployment itself. + deploymentLabels: {} podAnnotations: {} # Extra pod labels, merged into the chart's selector labels. Do not # re-declare `app.kubernetes.io/name` / `instance` / `component` here: they @@ -565,6 +573,10 @@ backend: enabled: false minAvailable: "" maxUnavailable: "" + # Extra labels on the backend Deployment itself. + deploymentLabels: {} + # Extra annotations on the backend Deployment itself. + deploymentAnnotations: {} podAnnotations: {} # Same shape as the gateway blocks of the same name. podLabels: {} @@ -634,6 +646,10 @@ ui: enabled: false minAvailable: "" maxUnavailable: "" + # Extra labels on the ui Deployment itself. + deploymentLabels: {} + # Extra annotations on the ui Deployment itself. + deploymentAnnotations: {} podAnnotations: {} # Same shape as the gateway blocks of the same name. The nginx runtime # writes its pid, cache, and proxy temp files under /tmp, so it boots as