Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • kubectl get pods -o=name
  • kubectl get pods -o=name |  sed "s/^.\{4\}//" | grep <release name>
  • kubectl get pods --no-headers -o custom-columns=":metadata.name" | grep <release name>
  • kubectl get pod -A | grep <release name> | awk '{print $2}'.    // find a POD by release name
  • kubectl get --no-headers=true pods -o name | awk -F "/" '{print $2}'

Get PoD status

  • kubectl get pods <pod name> --no-headers -o custom-columns=":status.phase"


Others

  • kubectl get ns -A
  • kubectl get pods - n <namespace>
  • kubectl get pod -o=custom-columns=NAME:.metadata.name,NODE:.spec.nodeName
  • kubectl get pod -o=custom-columns=NAME:.metadata.name,NODE:.spec.nodeName | awk '{print $2}'.                                         // get the node name
  • kubectl get pod -o=custom-columns=NAME:.metadata.name,NODE:.spec.nodeName | grep <release name>.                               // get the pod and node names for release name
  • kubectl get pod -o=custom-columns=NAME:.metadata.name,NODE:.spec.nodeName | grep <release name> | awk '{print $2}'.  // get the node name for release name
  • kubectl describe pods <pod name>       // get a pod description
  • kubectl describe pods <pod name> | grep 'Container ID'.    // get container id(s) from a pod
  • kubectl get pod <pod name>  -o="custom-columns=NAME:.metadata.name,INIT-CONTAINERS:.spec.initContainers[*].name,CONTAINERS:.spec.containers[*].name".   // get pod, init-container and containers
  • kubectl get pods <pod name>  -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}'.   // get container name(s) from the pod name
  • kubectl exec -it <pod name> -c <container name> bash.  // access pod

...