【Azure K8S|AKS】进入AKS的POD中查看文件,例如PVC Volume Mounts使用情况

问题描述

在昨天的文章中,创建了 Disk + PV + PVC + POD 方案(https://www.cnblogs.com/lulight/p/17604441.html),那么如何进入到POD之中去查看文件呢? 如PVC Volume Mounts中文件?

 

问题解答

第一步:进入POD内部(查看文件)

使用  kubectl exec -it  <your pod name> -- /bin/sh 

 

第二步:在 /mnt/testazure 文件中创建txt文件

注: /mnt/testazure  文件在POD的yaml文件中,预先指定。

使用echo写入txt文件

/mnt/testazure # echo "this is test file for AKS POD PVC,PC,DISK " > test1.txt
/mnt/testazure # echo "this is test file for AKS POD PVC,PC,DISK " > test2.txt
/mnt/testazure # echo "this is test file for AKS POD PVC,PC,DISK " > test3.txt
/mnt/testazure # echo "this is test file for AKS POD PVC,PC,DISK " > test5.txt
/mnt/testazure # echo "this is test file for AKS POD PVC,PC,DISK " > test4.txt
/mnt/testazure # echo "this is test file for AKS POD PVC,PC,DISK " > test6.txt

 

第三步:通过kubectl exec 命令统计指定文件夹的使用信息

命令为: kubectl exec  -it mypod-pv-pvc-test  -- df -h /mnt/testazure

显示文件夹的Size,使用占比等情况

 

 

参考资料

Get a Shell to a Running Container : https://kubernetes.io/docs/tasks/debug/debug-application/get-shell-running-container/

在不停机的情况下,调整永久性卷的大小: https://docs.azure.cn/zh-cn/aks/azure-disk-csi#resize-a-persistent-volume-without-downtime

 
 

 

posted @ 2023-08-04 20:05  路边两盏灯  阅读(49)  评论(0编辑  收藏  举报