由于容器的 Azure Monitor 将从控制台收集基本日志,即标准输出/标准错误。是否有任何理由为日志传送实施 Sidecar,特别是对于生产工作负载?目前我正在使用以下模式
apiVersion: apps/v1
kind: Deployment
metadata:
name: sidecar-logshipping
spec:
replicas: 2
selector:
matchLabels:
app: sidecar-logshipping
template:
metadata:
labels:
app: sidecar-logshipping
spec:
containers:
- name: main-container
image: busybox
args:
- /bin/sh
- -c
- >
i=0;
while true;
do
echo "$i: $(date) dog" >> /var/log/mylogs/app.log;
i=$((i+1));
sleep 1;
done
resources:
limits:
memory: "256Mi"
cpu: "500m"
requests:
memory: "64Mi"
cpu: "250m"
volumeMounts:
- name: logs
mountPath: /var/log/mylogs
- name: log-shipper
image: busybox
args: [/bin/sh, -c, 'tail -n+1 -f /var/log/mylogs/*.log']
resources:
limits:
memory: "256Mi"
cpu: "500m"
requests:
memory: "64Mi"
cpu: "250m"
volumeMounts:
- name: logs
mountPath: /var/log/mylogs
volumes:
- name: logs
emptyDir: {}