Skip to content

helm: set default webapp container and add extraVolumes #2222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hosting/k8s/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: trigger
description: The official Trigger.dev Helm chart
type: application
version: 4.0.0-beta.12
version: 4.0.0-beta.14
appVersion: trigger-helm-rc.1
home: https://trigger.dev
sources:
Expand Down
11 changes: 9 additions & 2 deletions hosting/k8s/helm/templates/webapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ spec:
{{- include "trigger-v4.componentSelectorLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 6 }}
template:
metadata:
{{- with .Values.webapp.podAnnotations }}
annotations:
kubectl.kubernetes.io/default-container: webapp
{{- with .Values.webapp.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Comment on lines +52 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Potential duplicate-key collision in metadata.annotations

A hard-coded kubectl.kubernetes.io/default-container annotation is added before user-supplied podAnnotations. If a user also defines this key, Helm will render two identical keys and fail with:

Error: YAML parse error on ...: found duplicate key "kubectl.kubernetes.io/default-container"

Consider merging the maps so the user can still override when necessary:

-        kubectl.kubernetes.io/default-container: webapp
-        {{- with .Values.webapp.podAnnotations }}
-        {{- toYaml . | nindent 8 }}
-        {{- end }}
+        {{- $base := dict "kubectl.kubernetes.io/default-container" "webapp" }}
+        {{- $anns := mergeOverwrite $base (default dict .Values.webapp.podAnnotations) }}
+        {{- toYaml $anns | nindent 8 }}

This keeps the default while remaining user-configurable.

🤖 Prompt for AI Agents
In hosting/k8s/helm/templates/webapp.yaml around lines 52 to 55, the annotation
kubectl.kubernetes.io/default-container is hard-coded before user
podAnnotations,
which can cause duplicate key errors if the user also sets this annotation. To
fix,
merge the default annotation with the user-supplied podAnnotations map so that
the
user can override the default value. Use Helm's merge function or a similar
approach
to combine the maps before rendering them, ensuring no duplicate keys appear.

labels:
{{- include "trigger-v4.componentSelectorLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 8 }}
spec:
Expand Down Expand Up @@ -323,6 +324,9 @@ spec:
volumeMounts:
- name: shared
mountPath: /home/node/shared
{{- with .Values.webapp.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: shared
{{- if .Values.persistence.shared.enabled }}
Expand All @@ -331,6 +335,9 @@ spec:
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.webapp.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.webapp.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
20 changes: 20 additions & 0 deletions hosting/k8s/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ webapp:
# name: my-secret
# key: secret-key

# Extra volumes for the webapp pod
extraVolumes:
[]
# - name: config-volume
# configMap:
# name: my-config
# - name: secret-volume
# secret:
# secretName: my-secret
Comment on lines +118 to +126
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

extraVolumes is parsed as a string, breaking Helm rendering

Placing the literal [] on the next line indents it as a scalar under the key, not as the empty list you intended.
toYaml will therefore output '[]', and the with block in templates/webapp.yaml will inject a quoted string inside spec.volumes, yielding invalid Kubernetes YAML.

-  extraVolumes:
-    []
+  # Extra volumes for the webapp pod
+  extraVolumes: []

Apply the same pattern used by numerous stable charts (key: []) to ensure the value is an actual empty sequence.

🤖 Prompt for AI Agents
In hosting/k8s/helm/values.yaml around lines 118 to 126, the extraVolumes key is
assigned a literal '[]' on the next line, causing it to be parsed as a string
instead of an empty list, which breaks Helm rendering. Fix this by assigning
extraVolumes directly to an empty list using the inline syntax (extraVolumes:
[]) without indentation or quotes, matching the pattern used in stable charts to
ensure it is parsed as an actual empty sequence.


# Extra volume mounts for the webapp container
extraVolumeMounts:
[]
# - name: config-volume
# mountPath: /etc/config
# readOnly: true
# - name: secret-volume
# mountPath: /etc/secrets
# readOnly: true
Comment on lines +128 to +136
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same issue for extraVolumeMounts

The misplaced [] will be treated as a string, leading to a quoted entry under volumeMounts and a failed deployment.

-  extraVolumeMounts:
-    []
+  # Extra volume mounts for the webapp container
+  extraVolumeMounts: []

Fixing both blocks keeps the chart installable even when users do not override these values.

🤖 Prompt for AI Agents
In hosting/k8s/helm/values.yaml around lines 128 to 136, the extraVolumeMounts
field is incorrectly set to an empty list using square brackets on a separate
line, which YAML interprets as a string, causing deployment failures. Replace
the line containing [] with a properly formatted empty list by removing the
brackets and ensuring the field is an empty array without quotes or misplaced
characters, so the Helm chart remains installable when users do not override
this value.


# ServiceMonitor for Prometheus monitoring
serviceMonitor:
enabled: false
Expand Down