This topic describes how to mount stdlog to access a container's standard output logs as files within an ECI Pod. The logs are mounted with root permissions.
Configuration example
You can use the CSI plug-in to mount a container's standard output logs into an ECI Pod with root permissions.
-
Create a YAML configuration file.
vim stdlog_demo.yamlapiVersion: v1 kind: Pod metadata: name: test-stdlog-demo spec: containers: - image: registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2 name: test-container volumeMounts: - mountPath: /cache-test name: cache-volume volumes: - name: cache-volume csi: driver: stdlogplugin.csi.alibabacloud.com -
Deploy the Pod.
kubectl create -f stdlog_demo.yaml -
Verify the result.
The output shows that the container's standard output logs are mounted to the
/cache-testdirectory with root permissions. You can now access these logs from within the container.kubectl get pod test-stdlog-demo kubectl exec -it test-stdlog-demo bash ls -l /cache-test ls -l /cache-test/test-containershell@Alicloud:~$ kubectl get pod test-stdlog-demo NAME READY STATUS RESTARTS AGE test-stdlog-demo 1/1 Running 0 76s shell@Alicloud:~$ kubectl exec -it test-stdlog-demo bash kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in root@test-stdlog-demo:/# ls -l /cache-test total 4 drwxr-xr-x 2 root root 4096 Jul 6 09:04 test-container root@test-stdlog-demo:/# ls -l /cache-test/test-container total 0 -rw-r----- 1 root root 0 Jul 6 09:04 0.log root@test-stdlog-demo:/#