Skip to content

Commit

Permalink
update a bit, add image
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Prince committed Dec 11, 2020
1 parent adb0d0a commit 26fe42f
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions Dev/Kubernetes/k-get-pods.30s.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
#!/usr/bin/env bash

# <bitbar.title>List running Kubernetes pods (default namespace)</bitbar.title>
# <bitbar.title>List some running Kubernetes things</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Robert Prince</bitbar.author>
# <bitbar.author.github>robertp</bitbar.author.github>
# <bitbar.desc>Simple that shows running Kubernetes pods; it's just output from 'kubectl get pods' with a font specified. It assumes you have installed kubectl using brew.</bitbar.desc>
# <bitbar.desc>Simple plugin that shows running Kubernetes pods, services, deployments, ...</bitbar.desc>
# <bitbar.dependencies>brew,kubectl</bitbar.dependencies>
# <bitbar.image>https://i.imgur.com/sH9yhBW.png</bitbar.image>

export PATH=/usr/local/bin:"${PATH}"

numpods=$(kubectl get pods -A 2> /dev/null | grep -v NAME | wc -l)
echo "$numpods pods running"
numpods=$(kubectl get pods -A 2> /dev/null | grep -v NAME | wc -l | sed 's/ //g')
numsvc=$(kubectl get services -A 2> /dev/null | grep -v NAME | wc -l | sed 's/ //g')
numdeps=$(kubectl get deployments -A 2> /dev/null | grep -v NAME | wc -l | sed 's/ //g')

# if [[ "$numpods" -eq "0" && "$numsvc" -eq "0" && "$numdeps" -eq "0" ]]; then echo "no k8s"; exit; fi

if [[ "$numpods" -eq "0" && "$numsvc" -eq "0" && "$numdeps" -eq "0" ]]; then exit; fi

echo "[$numpods pods / $numsvc services / $numdeps deployments]"

echo "---"
if [[ "$numpods" -eq 0 ]]; then exit; fi
echo "==== PODS ===="
kubectl get pods -A | while read -r line; do echo "${line} | font=Menlo"; done
echo "---"
echo "==== SERVICES ===="
kubectl get services -A | while read -r line; do echo "${line} | font=Menlo"; done
echo "---"
echo "==== DEPLOYMENTS ===="
kubectl get deployments -A | while read -r line; do echo "${line} | font=Menlo"; done

0 comments on commit 26fe42f

Please sign in to comment.