[英]How to collect logs of every job of a Kubernetes CronJob for a period of time?
[英]Save logs from kubernetes pod for a period of time
kubernetes中如何保存一段时间的pod日志。 我可以渲染像 kubectl logs POD_NAME 这样的日志,但是如何将它们保存到文件中?
在您的应用程序 pod 中,使用volumeMounts
将日志写入文件系统中的路径。
从此处的文档中,使用带有日志代理(例如fluentbit )的 sidecar 容器将写入文件系统的日志发送到集中式日志后端,例如 splunk 或 Elasticsearch。
apiVersion: apps/v1
kind: Deployment
metadata:
name: fluentbit-logging-sidecar
spec:
selector:
matchLabels:
app: fluentbit-logging-sidecar
replicas: 1
template:
metadata:
labels:
app: fluentbit-logging-sidecar
volumes:
- name: shared-data
emptyDir: {}
- name: config-volume
configMap:
name: fb-agent-config
containers:
- name: sample-logging
image: <image>
volumeMounts:
- name: shared-data
mountPath: /app/logs
- name: fb-sidecar
image: fluent/fluent-bit
volumeMounts:
- name: shared-data
mountPath: /app/logs
- name: config-volume
mountPath: /fluent-bit/etc/fluent-bit.conf
subPath: fluent-bit.conf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.