A developer may want to provide additional features for their application, such as sending logs to an external endpoint.
Developers can write these features directly into an application’s container, or they can create a “sidecar” container that does some of this work.
One common example of a sidecar feature may be to include a FluentBit container in your pod that sends log data to an Elastic Search database. This can be used for customizable metrics monitoring, or system debugging.
Workflow for including FluentBit sidecar container:
Path
to your container’s log directory{{- define "namespace" -}}
{{- .Release.Namespace | trimPrefix "slate-vo-" | printf " %s" -}}
{{- end -}}
...
containers:
- name: fluent-bit
image: fluent/fluent-bit:0.13.4
imagePullPolicy: IfNotPresent
volumeMounts:
- name: {{ template "[chart].fullname" . }}-fluent-bit-config
mountPath: /fluent-bit/etc/
- name: varlog
mountPath: /var/log
...
volumes:
- name: {{ template "[chart].fullname" . }}-fluent-bit-config
configMap:
name: {{ template "[chart].fullname" . }}-fluent-bit-config
- name: varlog
emptyDir: {}
...
where varlog
is mounted to FluentBit and to your container’s log directory.