Skip to content

Instantly share code, notes, and snippets.

@vnugent
Last active August 29, 2015 14:07
Show Gist options
  • Save vnugent/c81b4161a99162bec57c to your computer and use it in GitHub Desktop.
Save vnugent/c81b4161a99162bec57c to your computer and use it in GitHub Desktop.
kubernetes cheatsheet
#list all pod Ids
/usr/bin/kubectl get -o json pods |jq --raw-output '.items | .[] |.metadata|.name'

# delete all pods
/usr/bin/kubectl get -o json pods |jq --raw-output '.items | .[] | .metadata | .name' | xargs --no-run-if-empty -I name /usr/bin/kubectl delete pods name 

# delete all services
/usr/bin/kubectl get -o json services |jq --raw-output '.items | .[] | .id'  | xargs --no-run-if-empty -I name /usr/bin/kubectl delete services name

Older version

# list all pod IDs
kubecfg -json list pods |jq --raw-output '.items | .[] |.id'

# delete all pods
kubecfg -json list pods |jq --raw-output '.items | .[] |.id' | xargs --no-run-if-empty -I name  kubecfg delete pods/name

# delete all services
kubecfg -json list services |jq --raw-output '.items | .[] |.id' | xargs --no-run-if-empty -I name  kubecfg delete services/name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment