BetaThis is a live doc! Anyone with edit access can make updates in real time without having to publish.
批量删除处于某一状态的 Pod
# 删除某一 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 但不持久化
Dry Run 的实现是在服务器侧的,可以用来验证提交的信息是否正确,且会根据服务器的配置去增加一些元字段,但是最终变更不会被写入持久化
Dry Run 通常与 -o yaml 一起使用以预览生成的 yaml