Extra Containers
Add additional containers via chart.extraContainers with the full Kubernetes Container specification, custom ports, and dedicated volume mounts.
Extra Containers
With chart.extraContainers, you can add any number of additional containers to a pod — independent of the structured chart.sidecar. Entries are passed through verbatim as Kubernetes Container objects into spec.template.spec.containers of Deployment, StatefulSet, and DaemonSet workloads.
When to Use extraContainers Instead of sidecar?
| Requirement | chart.sidecar |
chart.extraContainers |
|---|---|---|
| A single companion container sharing the main container's volumes | Ideal (useContainerVolume: true) |
Possible |
| More than one companion container in the pod | Not possible (single sidecar only) | Unlimited |
Expose dedicated container ports (ports:) |
Not supported | Fully supported |
Individual volumeMounts (different from the main container) |
Not supported | Fully supported |
Full Kubernetes Container spec (lifecycle, stdin, tty, workingDir, etc.) |
Predefined fields only | Fully supported |
Configuration
Each element in chart.extraContainers must satisfy the full Kubernetes requirements of a Container object (most notably a unique name and a valid image). Any volumes referenced in volumeMounts must be declared in the corresponding workload volume block (deploymentVolume.volumes, statefulsetVolume.volumes, or daemonsetVolume.volumes).
Example: Nginx Frontend with PHP-FPM and Metrics Exporter
chart:
enabled: true
fullnameOverride: "acme-php-app"
container:
image: nginxinc/nginx-unprivileged:1.27-alpine
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 250m
memory: 128Mi
extraContainers:
- name: php-fpm
image: php:8.3-fpm-alpine
ports:
- name: fpm
containerPort: 9000
protocol: TCP
env:
- name: APP_ENV
value: production
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
volumeMounts:
- name: app-code
mountPath: /var/www/html
readOnly: true
- name: nginx-exporter
image: nginx/nginx-prometheus-exporter:1.3.0
args:
- "--nginx.scrape-uri=http://127.0.0.1:8080/stub_status"
ports:
- name: metrics
containerPort: 9113
protocol: TCP
livenessProbe:
httpGet:
path: /metrics
port: metrics
initialDelaySeconds: 10
periodSeconds: 15
resources:
requests:
cpu: 20m
memory: 32Mi
limits:
cpu: 100m
memory: 64Mi
deploymentVolume:
volumeMounts:
- name: app-code
mountPath: /var/www/html
readOnly: true
- name: nginx-conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
readOnly: true
volumes:
- name: app-code
emptyDir: {}
- name: nginx-conf
configMap:
name: acme-nginx-conf
service:
type: ClusterIP
ports:
- name: http
port: 80
targetPort: http
- name: metrics
port: 9113
targetPort: metrics
Important Notes
- No automatic env splitting: Inside
extraContainers, only native Kubernetes fields (envandenvFrom) apply —staticEnvandextraEnvdo not exist there. - Unique container names: In the template, the main container is named
{{ .Chart.Name }}(usuallyohmyhelm) and the optional sidecar is named{{ .Chart.Name }}-sidecar. Always choose distinct, unique names forextraContainers[].name. - List replacement in Helm: If you specify
extraContainersin an overlay file (values-prod.yaml), Helm replaces the entire list from the basevalues.yaml.