Multi-Container Pods
Kubernetes multi-container pod example using a sidecar pattern with a Filebeat log collector alongside an event simulator application.
This manifest demonstrates the sidecar container pattern. The main app container generates events and writes logs to a shared volume. The sidecar container runs Filebeat to collect and forward those logs. Both containers mount the same log-volume to share data.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
apiVersion: v1
kind: Pod
metadata:
labels:
name: app
name: app
namespace: elastic-stack
spec:
containers:
- image: kodekloud/event-simulator
name: app
volumeMounts:
- mountPath: /log
name: log-volume
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-7lfvx
readOnly: true
- image: kodekloud/filebeat-configured
name: sidecar
volumeMounts:
- mountPath: /var/log/event-simulator/
name: log-volume
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-7lfvx
readOnly: true
serviceAccount: default
serviceAccountName: default
volumes:
- hostPath:
path: /var/log/webapp
type: DirectoryOrCreate
name: log-volume
- name: default-token-7lfvx
secret:
defaultMode: 420
secretName: default-token-7lfvx
This post is licensed under CC BY 4.0 by the author.