Sidecar Container
Run companion containers with chart.sidecar and shared volumes via useContainerVolume, or switch to extraContainers when dedicated ports are needed.
Sidecar Container
With chart.sidecar, you add a second container named <chartName>-sidecar to your workload (Deployment, StatefulSet, or DaemonSet). Typical use cases include log forwarders, local proxies, and configuration synchronizers.
Supported Fields of chart.sidecar
| Field | Default | Description |
|---|---|---|
enabled |
false |
Enables the sidecar container |
image |
nodered/node-red:latest |
Container image including tag (required by schema) |
useContainerVolume |
false |
When true, mounts the exact same volumeMounts as the main container |
imageConfig.pullPolicy |
IfNotPresent |
Always, IfNotPresent, or Never |
securityContext |
{} |
Container securityContext |
command / args |
[] |
Overrides entrypoint and arguments |
staticEnv / env / extraEnv / envFrom |
[] |
Environment variables (same as the main container; env is required by schema) |
livenessProbe / readinessProbe / startupProbe |
— | Health checks — always use a numeric port |
resources |
— | requests and limits for CPU and memory |
Example: Logging Sidecar with Shared Volume (useContainerVolume: true)
In this example, the main application writes logs to a shared emptyDir volume, which the sidecar reads at the same path via useContainerVolume: true:
chart:
enabled: true
fullnameOverride: "acme-web"
container:
image: registry.acme.corp/web:1.4.0
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
sidecar:
enabled: true
image: fluent/fluent-bit:3.1
useContainerVolume: true
args:
- "-i"
- "tail"
- "-p"
- "path=/var/log/acme/*.log"
- "-o"
- "stdout"
env:
- name: FLUSH_INTERVAL
value: "5"
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 150m
memory: 128Mi
livenessProbe:
httpGet:
path: /api/v1/health
port: 2020
initialDelaySeconds: 10
periodSeconds: 15
deploymentVolume:
volumeMounts:
- name: shared-logs
mountPath: /var/log/acme
volumes:
- name: shared-logs
emptyDir: {}
service:
type: ClusterIP
ports:
- name: http
port: 80
targetPort: http
How useContainerVolume Works
Depending on the active workload type, setting useContainerVolume: true automatically attaches the corresponding volumeMounts block to the sidecar:
- For
Deployment:chart.deploymentVolume.volumeMounts - For
StatefulSet:chart.statefulsetVolume.volumeMounts - For
DaemonSet:chart.daemonsetVolume.volumeMounts
When useContainerVolume: false (default), the sidecar receives no volumeMounts.
Choosing Between sidecar and extraContainers
- Choose
chart.sidecarwhen you need exactly one companion container that does not need to expose its own service ports and either mounts no volumes or mounts the exact same volumes as the main container. - Choose
chart.extraContainersas soon as you need customvolumeMounts(for example,readOnly: trueonly for the sidecar), dedicatedports(for example, a metrics exporter), or multiple additional containers in the same Pod.