-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix): add support for OpenEBS local PVs #2
Conversation
Signed-off-by: ksatchit <karthik.s@mayadata.io>
Signed-off-by: ksatchit <karthik.s@mayadata.io>
@@ -51,7 +55,7 @@ function collect_pv_utilization_metrics(){ | |||
|
|||
for i in ${pv_list[@]} | |||
do | |||
pv_mount_list+=($(df -h | grep ${i} | awk '{print $NF}')) | |||
pv_mount_list+=($(findmnt --df | grep ${i} | grep '/var/lib/kubelet/pods' | head -1 | awk '{print $NF}')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking out loud, the path can be varying depending on the K8s distribution.
For example, in RKE, the path is /opt/rke/var/lib/kubelet/pods
, this code will work even for RKE as the match is available. However, would it still be better to make this configurable via ENV? Maybe a future PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Kiran..agreed 👍
Signed-off-by: ksatchit <karthik.s@mayadata.io>
Changes
This PR consists of some small improvements to the existing monitor-pv bash script.
Uses
findmnt --df
as a way to determine PV mount points over usingdf
. The local PV mounts do not show up in case of the latter. Findmnt has a broader reach, i.e., looks for filesystems in/etc/mtab
,/etc/fstab
&/proc/self/mountinfo
by default. the--df
flag (outputs in similar format as df) has been used to enable simpler command output parse.The mount points for a given PV are filtered to the one in this path
var/lib/kubelet/pods
as this is the constant in a list of several mounts (including those depending on PV type and Cluster type. For example,/var/lib/kubelet/plugins/
,/home/kubernetes/containerized_mounter/
)Fixes the command to obtain volume capacity in bytes
cut
doesn't accept multi-character delimiter, sotr
is used insteadAdds a sample deployment spec that uses openebs namespace and serviceaccount.
Signed-off-by: ksatchit karthik.s@mayadata.io