feat(helm): add a jsonLogs value to the litellm-helm chart

The proxy already supports JSON logging through JSON_LOGS, but the chart
exposed no option for it, so operators shipping to a centralized log system
had to discover the variable and hand-roll it through envVars.

jsonLogs: true injects JSON_LOGS=True. Because the proxy reads it as
bool(os.getenv("JSON_LOGS", False)), any non-empty value is truthy, so
jsonLogs: false omits the variable rather than setting it to a falsy-looking
string. Defining JSON_LOGS in envVars still wins, matching how logLevel
already defers to envVars.
This commit is contained in:
Aryan Pardeshi 2026-08-11 01:44:12 +05:30
parent 9bca9dfbb1
commit 79da804ac6
4 changed files with 54 additions and 0 deletions

View file

@ -29,6 +29,7 @@ If `db.useStackgresOperator` is used (not yet implemented):
| `masterkey` | The Master API Key for LiteLLM. If not specified, a random key in the `sk-...` format is generated. | N/A |
| `environmentSecrets` | An optional array of Secret object names. The keys and values in these secrets will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` |
| `environmentConfigMaps` | An optional array of ConfigMap object names. The keys and values in these configmaps will be presented to the LiteLLM proxy pod as environment variables. See below for an example Secret object. | `[]` |
| `jsonLogs` | Emit logs as JSON instead of plain text, by setting `JSON_LOGS=True` on the proxy pod. Covers uvicorn's access and error logs alongside LiteLLM's own. Defining `JSON_LOGS` in `envVars` takes precedence. | `false` |
| `image.repository` | LiteLLM Proxy image repository | `docker.litellm.ai/berriai/litellm` |
| `image.pullPolicy` | LiteLLM Proxy image pull policy | `IfNotPresent` |
| `image.tag` | Overrides the image tag whose default the latest version of LiteLLM at the time this chart was published. | `""` |

View file

@ -133,6 +133,14 @@ spec:
- name: LITELLM_LOG
value: {{ .Values.logLevel | quote }}
{{- end }}
{{- /*
JSON_LOGS is truthy for any non-empty value, so it is injected only when
jsonLogs is on and omitted entirely otherwise.
*/}}
{{- if and .Values.jsonLogs (not (hasKey (default dict .Values.envVars) "JSON_LOGS")) }}
- name: JSON_LOGS
value: "True"
{{- end }}
{{- if .Values.envVars }}
{{- range $key, $val := .Values.envVars }}
- name: {{ $key }}

View file

@ -402,3 +402,38 @@ tests:
- equal:
path: spec.template.metadata.annotations["example.com/literal"]
value: "plain-string-value"
- it: should not set JSON_LOGS by default
template: deployment.yaml
asserts:
- notContains:
path: spec.template.spec.containers[0].env
content:
name: JSON_LOGS
value: "True"
- it: should set JSON_LOGS when jsonLogs is enabled
template: deployment.yaml
set:
jsonLogs: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: JSON_LOGS
value: "True"
- it: should let envVars win over jsonLogs instead of emitting JSON_LOGS twice
template: deployment.yaml
set:
jsonLogs: true
envVars:
JSON_LOGS: "1"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: JSON_LOGS
value: "1"
- notContains:
path: spec.template.spec.containers[0].env
content:
name: JSON_LOGS
value: "True"

View file

@ -459,6 +459,16 @@ migrationJob:
# this injection entirely when envVars already defines LITELLM_LOG.
logLevel: INFO
# Emit logs as JSON instead of the default plain text (sets JSON_LOGS=True in the
# deployment env), for centralized log systems that would otherwise need a custom
# parser. Covers uvicorn's access and error logs as well as LiteLLM's own.
#
# JSON_LOGS is truthy for any non-empty value, so the variable is injected only
# when this is true and left out entirely when it is false. Defining JSON_LOGS
# inside `envVars:` below wins: the template skips this injection when envVars
# already defines it.
jsonLogs: false
# Additional environment variables to be added to the deployment as a map of key-value pairs
envVars: {}