All Products
Search
Document Center

Use FlexVolume to mount standard output logs

Last Updated: Sep 24, 2021

This topic describes how to use FlexVolume to mount standard output logs of a container to an elastic container instance. You must have root permissions to perform this operation.

Prerequisites

Virtual Kubelet is deployed in your Kubernetes cluster.

Note

By default, Alibaba Cloud Serverless Kubernetes (ASK) clusters are integrated with Virtual Kubelet. For other types of clusters, you must deploy Virtual Kubelet in the clusters. For more information, see Connect Kubernetes to Elastic Container Instance.

Configuration example

Elastic Container Instance allows you to use FlexVolume to mount standard output logs of a container to an elastic container instance. You must have root permissions to perform this operation. The following example shows the configuration procedure:

  1. Prepare the YAML configuration file.

    vim flexvolume_stdlog.yaml

    The following example shows the content of the flexvolume_stdlog.yaml file.

    apiVersion: v1
    kind: Pod
    metadata:
      name: test-flexvolume-stdlog
    spec:
      containers:
      - image: nginx:latest
        name: test-container
        volumeMounts:
        - mountPath: /cache-test
          name: cache-volume
      volumes:
      - name: cache-volume
        flexVolume:
          driver: alicloud/pod-stdlog
  2. Deploy a pod.

    kubectl create -f flexvolume_stdlog.yaml
  3. View the mount result.

    Run the ls command to view the file directory in the pod. The standard output logs of the container are mounted to the /cache-test directory of the pod. You can use the logs in the container.

    stdlog