Updated on 2026-04-28 GMT+08:00

Mounting Standard Output Logs

This section describes how to mount standard output logs to containers for easy log retrieval.

Constraints

volume.cci.io/mount-stdlog-containers and volume.cci.io/mount-stdlog-containers-path cannot be configured at the same time.

Using a YAML File

The following is an example that shows how to configure this function during workload creation, with the key configuration marked in red:

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  #Name of the containers whose standard output logs are to be mounted
    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%
Table 1 Pod annotations

Annotation

Type

Description

Example Value

volume.cci.io/mount-stdlog-containers

String

  1. Specify the names of the containers whose standard output logs are to be mounted. Separate multiple containers with commas (,). You can also set the value to an asterisk (*) to mount the standard output logs of all containers. If the value is set to *, it cannot be set to any other container name.
  2. After the containers that match the annotation start, the directory that contains the standard output logs of all containers in the pod is mounted to the /var/log/pods directory of each container.

Example 1:

"container-0,container-1"

Example 2:

"*"

volume.cci.io/mount-stdlog-containers-path

String

  1. Specify the container names and mount paths in the containers in JSON format. If the container name is set to *, the logs of all containers are mounted. If the value is set to *, it cannot be set to any other container name.
  2. After the containers that match the annotation start, the directory that contains the standard output logs of all containers in the pod is mounted to the specified path of each container.

Example 1:

"{\"container-0\":\"/var/log/pods\",\"container-1\":\"/tmp/log/pods\"}"

Example 2:

"{\"*\":\"/tmp/log/pods\"}"