kubernetes

  • list pods for all namespaces

    kubectl get pods --all-namespaces
  • get list of containers in pod

    kubectl -n <namespace> get pods <pod_name> -o jsonpath='{.spec.containers[*].name}'
  • connect to shell on pod

    kubectl exec -it pods/demo -- /bin/bash
  • list all completed pods

kubectl get pod --field-selector=status.phase==Succeeded
  • delete all completed pods

    kubectl delete pod --field-selector=status.phase==Succeeded
  • delete all errored pods

    kubectl delete pod --field-selector=status.phase==Failed