forked from matryer/xbar-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Prince
committed
Dec 11, 2020
1 parent
adb0d0a
commit 26fe42f
Showing
1 changed file
with
20 additions
and
5 deletions.
There are no files selected for viewing
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
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 |