Updated on 2025-08-12 GMT+08:00

Mounting Standard Output Logs

This section describes how to mount container standard output logs in a pod to a specified container 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

This example 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 container where standard output logs are 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. Name of the container where standard output logs are mounted. To mount the standard output logs of multiple containers, separate their names 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 a pod that matches the annotation starts, the directory that contains the standard output logs of all containers in the pod is mounted to the /var/log/pods directory of the container.

Example 1:

"container-0,container-1"

Example 2:

"*"

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

String

  1. Container name and mount path that the standard output logs are mounted. The value is in JSON format. If the container name is set to *, the logs of all containers are mounted to the specified container. If the value is set to *, it cannot be set to any other container name.
  2. After any container that matches the annotation starts, the directory that contains the standard output logs of all containers in the pod is mounted to the specified path of the container.

Example 1:

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

Example 2:

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