File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 6565 value : /shared_vol
6666 - name : COLLECT_INTERVAL
6767 value : " 10"
68+ - name : PROVISIONER_WHITELIST
69+ value : " openebs.io/provisioner-iscsi,openebs.io/local"
6870 command :
6971 - /bin/bash
7072 args :
Original file line number Diff line number Diff line change 22
33FILEPATH=${TEXTFILE_PATH:=/ shared_vol}
44INTERVAL=${COLLECT_INTERVAL:= 10}
5+ PROVISIONERS=${PROVISIONER_WHITELIST:= openebs.io/ local}
56
67# # calculate_pv_capacity obtains the size of a PV in bytes
78function calculate_pv_capacity(){
@@ -73,16 +74,27 @@ function collect_pv_utilization_metrics(){
7374
7475while true
7576do
77+ provisioner_list=$( echo ${PROVISIONERS} | tr ' ,' ' ' )
7678 declare -a pv_list=()
7779
7880 # # Select only those PVs that are bound. Several stale PVs can exist.
7981 for i in $( kubectl get pv -o jsonpath=' {.items[?(@.status.phase=="Bound")].metadata.name}' )
8082 do
81- pv_list+=(${i} )
83+ # # Select only those PVs that are provisioned by the whitelisted provisioners
84+ # # Nested conditions in jsonpath filters are not supported yet. Ref: https://github.com/kubernetes/kubernetes/issues/20352
85+ if [[ ${provisioner_list} =~ $( kubectl get pv ${i} -o jsonpath=' {.metadata.annotations.pv\.kubernetes\.io/provisioned-by}' ) ]]
86+ then
87+ pv_list+=(${i} )
88+ fi
8289 done
8390
84- echo " pv_list: ${pv_list[@]} "
85- collect_pv_capacity_metrics;
86- collect_pv_utilization_metrics;
91+ echo " No. of PVs by specified provisioners: ${# pv_list[@]} "
92+
93+ if [[ ${# pv_list[@]} -ne 0 ]]; then
94+ echo " PV List: ${pv_list[@]} "
95+ collect_pv_capacity_metrics;
96+ collect_pv_utilization_metrics;
97+ fi
98+
8799 sleep ${INTERVAL}
88100done
You can’t perform that action at this time.
0 commit comments