apiVersion: v1
kind: Pod
metadata:
name: app-with-logging-sidecar
spec:
volumes:
name: shared-logs
emptyDir: {}
initContainers:
- name: log-shipper
image: alpine:latest
command: ['sh', '-c', 'tail -F /opt/logs.txt']
volumeMounts:
- name: shared-logs
mountPath: /opt
restartPolicy: Always
containers:
- name: main-app
image: alpine:latest
command: ['sh', '-c', 'while true; do echo "logging" >> /opt/logs.txt; sleep 1; done']
volumeMounts:
- name: shared-logs
mountPath: /opt
**log-shipper**
sidecar container tails the log file generated by the **main-app**
container.**shared-logs**
facilitates communication between the two containers.**content-generator**
container creates an HTML file that the **web-server**
container serves using NGINX.