Skip to content

Instantly share code, notes, and snippets.

@mike-weiner
Last active August 13, 2024 18:18
Show Gist options
  • Save mike-weiner/b08e3bda3b6d222e28629b446ed96937 to your computer and use it in GitHub Desktop.
Save mike-weiner/b08e3bda3b6d222e28629b446ed96937 to your computer and use it in GitHub Desktop.
Helpful `kubectl` Commands

Helpful kubectl Commands

This Markdown file is a collection of helpful kubectl commands that I repeadetly finding myself using.

Pods

  • Print the name of every container in a pod on a newline: kubectl get pod -n <namespace> <podname> -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}'
  • Print the name of every container (and its image) found inside of a pod: kubectl get pod -n <namespace> <podname> -o jsonpath='{range .spec.containers[*]}{.name}{" | "}{.image}{"\n"}{end}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment