I'm working on a k8s namespace environment and I have a pod and its pvc deployed in it.
When the pod transfers data on PVC I would know the percentage of memory used and free.
There is a way?
Asked
Active
Viewed 816 times
0

David Maze
- 130,717
- 29
- 175
- 215

Giuseppe Percuoco
- 111
- 1
- 5
-
1If your pod container has a shell, simply `kubectl exec` into the container's shell and execute a `df -h`. The PVC mount path should be listed by the command. – Lukman Oct 14 '21 at 14:06
-
Are you using `kubeadm`, `minikube` or `Managed Kubernetes Service` ? – matt_j Oct 15 '21 at 09:36
-
@matt_j I'm working on a KaaS, so I'm using kubectl. – Giuseppe Percuoco Oct 18 '21 at 08:06
1 Answers
0
You can probably use kubedf (it supports most KaaS) script to show PVC usage. It only requires kubectl proxy
to be running.
I will create an example to illustrate how it may work.
First, we need to download this script:
$ wget https://gist.githubusercontent.com/redmcg/60cfff7bca6f32969188008ad4a44c9a/raw/e5c5722e7b4a5725afe9217ebd05fb33a11d4571/kubedf
$ ls
kubedf
$ chmod a+x kubedf
After a successful installation, we nee to run kubectl proxy
:
$ kubectl proxy
Starting to serve on 127.0.0.1:8001
And from another terminal window, we can test how it works. I have two PV
and PVC
:
$ kubectl get pv,pvc
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/pvc-52db08b6-dbb0-4fd7-b5a3-f828bf83f5c5 1Gi RWO Delete Bound default/myclaim-2 standard 33m
persistentvolume/pvc-db341238-8e7c-425c-856d-546589fa8c69 1Gi RWO Delete Bound default/myclaim standard 43m
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/myclaim Bound pvc-db341238-8e7c-425c-856d-546589fa8c69 1Gi RWO standard 43m
persistentvolumeclaim/myclaim-2 Bound pvc-52db08b6-dbb0-4fd7-b5a3-f828bf83f5c5 1Gi RWO standard 33m
Let's use kubedf
to show PVC usage:
$ ./kubedf -h
PVC Size Used Avail Use%
myclaim 974M 101M 858M 10%
myclaim-2 974M 301M 658M 31%

matt_j
- 4,010
- 1
- 9
- 23