Skip to content

Commit

Permalink
add longhorn volume attachment check to check-k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
ogrand committed Jan 23, 2025
1 parent 0a7a373 commit 2f828ad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/scripts/check-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ checkClusterResources() {
if [ "${flagTimeout}" != "" ] ; then
printf "\n%bCluster \"${context}\" not available...%b\n" "${RED}" "${STD}"
else
result="$(echo "${result}" | grep -v " Ready " | awk '{printf "%-18s %s\n", $2, $1}' | sort)"
result="$(echo "${result}" | grep -v " Ready " | awk '{printf "%-24s %s\n", $2, $1}' | sort)"
if [ "${result}" != "" ] ; then
printf "\n%bSTATUS NODE%b\n${result}\n" "${GREEN}" "${STD}"
printf "\n%bSTATUS NODE%b\n${result}\n" "${GREEN}" "${STD}"
fi

#--- Check pvcs
Expand All @@ -32,6 +32,12 @@ checkClusterResources() {
printf "\n%bSTATUS PV NAME%b\n${result}\n" "${GREEN}" "${STD}"
fi

#--- Check longhorn volumes attachment
result="$(kubectl get volumes.longhorn.io -n 02-longhorn -o json | jq -r '.items[]|.status.state + "/" + .status.robustness + " " + .metadata.name + " " + .status.kubernetesStatus.workloadsStatus[].podName + "/" + .spec.nodeID' | grep -v "attached/healthy" | awk '{printf "%-18s %-40s %s\n", $1, $2, $3}')"
if [ "${result}" != "" ] ; then
printf "\n%bSTATUS PVC POD/NODE%b\n${result}\n" "${GREEN}" "${STD}"
fi

#--- Check suspended/not ready flux resources (kustomization, helmchart, helmrelease, helmrepository, gitrepository)
result="$(flux get all -A --context ${context} | tr -s '\t' ' ' | grep -E "kustomization/|helmchart/|helmrelease/|helmrepository/|gitrepository/" | grep -E " False | True | Unknown " | sed -e "s+ +|+" | sed -E "s+ (False|True|Unknown) (False|True|Unknown)(.*)+|\1 \2+" | sed -e "s+ .*|+|+" -e "s+|+ +g" | awk '{
namespace=$1
Expand Down

0 comments on commit 2f828ad

Please sign in to comment.