Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Autosaved
Table of Contents
stylenone

利用环境变量指定 namespace

...

批量删除处于某一状态的 Pod

Code Block
breakoutModewide
languagebash
# 删除某一 NS 下的
kubectl get pod -n NS | grep Evicted | awk '{print "kubectl delete po -n NS ",$1}' | bash -x

# 删除全部 NS 下的
kubectl get pod -A | grep Evicted | awk '{print "kubectl delete po -n ",$1,$2}' | bash -x

# 利用 field selector
kubectl get pod -n NS --field-selector="status.phase==Failed"

Dry Run & Output & Diff

通过 --dry-run=client flag 可以让 k8s 仅仅生成&执行对应的 manifest 但不持久化

...