Skip to content

Instantly share code, notes, and snippets.

@bergman
Created February 14, 2017 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bergman/f0c895e718868cc0566b52e2371e5d48 to your computer and use it in GitHub Desktop.
Save bergman/f0c895e718868cc0566b52e2371e5d48 to your computer and use it in GitHub Desktop.
some useful kubectl customisations
# run like this:
# kubectl get nodes -o json | python nodes.py
import json
import sys
format = "%-45s %-12s %6s"
print format % ("NAME", "IP", "IMAGES")
for item in json.load(sys.stdin)["items"]:
print format % (item["metadata"]["name"],
item["status"]["addresses"][0]["address"],
sum([len(x["names"]) for x in item["status"]["images"]]))
@bergman
Copy link
Author

bergman commented Feb 14, 2017

this could probably be done with jq...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment