本文介紹如何掛載stdlog,實現將容器的標準輸出日誌以root許可權掛載到ECI Pod內。
配置樣本
ECI支援通過CSI儲存外掛程式,將容器的標準輸出日誌以root許可權掛載到ECI Pod內。配置樣本如下:
-
準備YAML設定檔。
vim stdlog_demo.yamlstdlog_demo.yaml的內容如下:
apiVersion: 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 -
部署Pod。
kubectl create -f stdlog_demo.yaml -
確認掛載結果。
查看Pod內的檔案目錄,可以看到容器的標準日誌已經以root許可權掛載到
/cache-test目錄下,您可以在容器內使用相關日誌。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:/#