{{/* Expand the name of the chart. */}} {{- define "litellm.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- 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). If release name contains chart name it will be used as a full name. */}} {{- define "litellm.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} {{- $name := default .Chart.Name .Values.nameOverride }} {{- if contains $name .Release.Name }} {{- .Release.Name | trunc 63 | trimSuffix "-" }} {{- else }} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} {{- end }} {{- end }} {{- end }} {{/* Create chart name and version as used by the chart label. */}} {{- define "litellm.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} {{- define "litellm.labels" -}} helm.sh/chart: {{ include "litellm.chart" . }} {{ include "litellm.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{/* Selector labels */}} {{- define "litellm.selectorLabels" -}} app.kubernetes.io/name: {{ include "litellm.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Enterprise billable-request metering. The client certificate identifies the deployment to LiteLLM's collector, so it is mounted read-only from an existing Secret rather than passed through the environment. */}} {{- define "litellm.billingMetrics.certDir" -}}/etc/litellm/billing-mtls{{- end -}} {{- define "litellm.billingMetrics.caDir" -}}/etc/litellm/billing-mtls-ca{{- end -}} {{- define "litellm.billingMetricsEnv" -}} - name: LITELLM_BILLING_METRICS_ENDPOINT value: {{ required "billingMetrics.endpoint is required when billingMetrics.enabled is true" .Values.billingMetrics.endpoint | quote }} - name: LITELLM_BILLING_METRICS_CLIENT_CERT value: {{ printf "%s/tls.crt" (include "litellm.billingMetrics.certDir" .) | quote }} - name: LITELLM_BILLING_METRICS_CLIENT_KEY value: {{ printf "%s/tls.key" (include "litellm.billingMetrics.certDir" .) | quote }} {{- if .Values.billingMetrics.caSecretName }} - name: LITELLM_BILLING_METRICS_CA_CERT value: {{ printf "%s/ca.crt" (include "litellm.billingMetrics.caDir" .) | quote }} {{- end }} {{- with .Values.billingMetrics.exportIntervalMs }} - name: LITELLM_BILLING_METRICS_EXPORT_INTERVAL_MS value: {{ . | quote }} {{- end }} {{- end -}} {{- define "litellm.billingMetricsVolumes" -}} - name: billing-metrics-mtls secret: secretName: {{ required "billingMetrics.secretName is required when billingMetrics.enabled is true (an existing Secret with tls.crt and tls.key)" .Values.billingMetrics.secretName }} {{- if .Values.billingMetrics.caSecretName }} - name: billing-metrics-mtls-ca secret: secretName: {{ .Values.billingMetrics.caSecretName }} {{- end }} {{- end -}} {{- define "litellm.billingMetricsVolumeMounts" -}} - name: billing-metrics-mtls mountPath: {{ include "litellm.billingMetrics.certDir" . }} readOnly: true {{- if .Values.billingMetrics.caSecretName }} - name: billing-metrics-mtls-ca mountPath: {{ include "litellm.billingMetrics.caDir" . }} readOnly: true {{- end }} {{- end -}} {{/* Create the name of the service account to use */}} {{- define "litellm.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} {{- default (include "litellm.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} {{/* Create the service account name used by migration jobs. When Helm hooks are enabled, pre-install/pre-upgrade hooks run before normal resources. If this chart is creating the ServiceAccount, it is not yet available for the hook job, so fall back to "default" (or an explicit override) to avoid a cyclic dependency. */}} {{- define "litellm.migrationServiceAccountName" -}} {{- if and .Values.migrationJob.hooks.helm.enabled .Values.serviceAccount.create }} {{- default "default" .Values.migrationJob.serviceAccountName }} {{- else }} {{- include "litellm.serviceAccountName" . }} {{- end }} {{- end }} {{/* Get redis service name. The bundled Redis subchart only serves sentinel in "replication" architecture (it rejects standalone + sentinel outright), and in that mode the sentinel Service is named "-redis", not "-redis-master". */}} {{- define "litellm.redis.serviceName" -}} {{- if .Values.redis.sentinel.enabled -}} {{- printf "%s-%s" .Release.Name (default "redis" .Values.redis.nameOverride | trunc 63 | trimSuffix "-") -}} {{- else -}} {{- printf "%s-%s-master" .Release.Name (default "redis" .Values.redis.nameOverride | trunc 63 | trimSuffix "-") -}} {{- end -}} {{- end -}} {{/* Get redis service port */}} {{- define "litellm.redis.port" -}} {{- if .Values.redis.sentinel.enabled -}} {{ .Values.redis.sentinel.service.ports.sentinel }} {{- else -}} {{ .Values.redis.master.service.ports.redis }} {{- end -}} {{- end -}}