【Azure K8S|AKS】进入AKS的POD中查看文件,例如PVC Volume Mounts使用情况 - LuBu0505/My-Code GitHub Wiki

问题描述

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

问题解答

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

使用  kubectl exec -it  -- /bin/sh  image.png

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

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

使用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

image.png

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

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

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

参考资料

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

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!