Created
November 22, 2023 20:50
-
-
Save fl64/3fb9187bcd2025cc3593bbad70fbc950 to your computer and use it in GitHub Desktop.
get vms and it's linstor nodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ns=tfprod | |
vms=$(kubectl -n ${ns} get pods -l vm.kubevirt.io/name -o json | jq '.items[] | select(.status.phase=="Running") | { ns: .metadata.namespace, name: .metadata.name, node: .spec.nodeName, claims: [.spec.volumes[] | select(.persistentVolumeClaim!=null) | .persistentVolumeClaim.claimName] }' -cr) | |
for vm in ${vms}; do | |
echo ${vm} | jq '. | {ns,name,node}' -c | |
pvcs=$(echo ${vm} | jq .claims[] -r) | |
for pvc in ${pvcs}; do | |
volume_name=$(kubectl -n ${ns} get pvc ${pvc} -o json | jq .spec.volumeName -r) | |
echo "${pvc} / ${volume_name}" | |
kubectl exec -n d8-linstor deploy/linstor-controller -- linstor r l -r ${volume_name} | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment