更新时间:2025-08-12 GMT+08:00
挂载容器标准输出日志
本节介绍如何将容器标准输出日志挂载到容器中,以支持从容器内部获取当前Pod各容器的标准输出日志。
约束与限制
“volume.cci.io/mount-stdlog-containers”和“volume.cci.io/mount-stdlog-containers-path”不支持同时配置。
通过YAML创建
已创建工作负载为例,配置示例如下,其中关键配置通过红色字体标出:
kind: Deployment
apiVersion: cci/v2
metadata:
name: deploy-example
namespace: namespace-example
spec:
replicas: 1
selector:
matchLabels:
app: deploy-example
template:
metadata:
labels:
app: deploy-example
annotations:
volume.cci.io/mount-stdlog-containers: sidecar #指定需要挂载容器标准输出日志的容器名
spec:
containers:
- name: nginx
image: nginx:latest
resources:
limits:
cpu: '1'
memory: 2Gi
requests:
cpu: '1'
memory: 2Gi
- name: sidecar
image: sidecar:latest
resources:
limits:
cpu: '0'
memory: '0'
requests:
cpu: '0'
memory: '0'
dnsPolicy: Default
imagePullSecrets:
- name: imagepull-secret
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 100%
Pod的注解 |
参数类型 |
描述 |
示例值 |
---|---|---|---|
volume.cci.io/mount-stdlog-containers |
String |
|
示例一: "container-0,container-1" 示例二: "*" |
volume.cci.io/mount-stdlog-containers-path |
String |
|
示例一: "{\"container-0\":\"/var/log/pods\",\"container-1\":\"/tmp/log/pods\"}" 示例二: "{\"*\":\"/tmp/log/pods\"}" |
父主题: 日志管理