k8s中pod删不掉
Posted 知识摆渡人
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s中pod删不掉相关的知识,希望对你有一定的参考价值。
问题现象:pod一直删除不掉
起因:在pod运行过程中,修改了其deployment,导致pod一直删不掉 操作过程:
- 删除pod,删不掉
- 强制删除pod,依然删除不了
- 删除deployment,旧的pod依然删不掉,因为deployment已经发生变更
- 查看pod的详情,发现如下ReplicaSet有关内容
kubectl get pods -n architect wx-xxx-luna-5b5755b69-zwrhb -oyaml
apiVersion: v1
kind: Pod
metadata:
annotations:
cni.projectcalico.org/podIP: 10.82.61.151/32
izone: default
kubectl.kubernetes.io/restartedAt: "2020-06-28T22:45:46+08:00"
sidecar.istio.io/status: {"version":"761ebc5a63976754715f22fcf548f05270fb4b8db07324894aebdb31fa81d960","initContainers":["istio-init"],"containers":["istio-proxy"],"volumes":["istio-envoy","istio-certs"],"imagePullSecrets":null}
creationTimestamp: "2021-05-28T04:29:27Z"
generateName: wx-xxx-luna-5b5755b69-
labels:
app: wx-xxx-luna
pod-template-hash: 5b5755b69
version: luna
name: wx-xxx-luna-5b5755b69-zwrhb
namespace: architect
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: ReplicaSet
name: wx-xxx-luna-5b5755b69
..............
- 删除这个ReplicaSet,pod被顺利删除
kubectl get pods -n architect |grep wx-xxx-luna
wx-xxx-luna-5b5755b69-zwrhb 2/2 Terminating 0 14m
wx-xxx-luna-7b8f7f895d-8lnkh 2/2 Running 0 6m31s
分析:
- 当我们通过deployment创建pod时,首先会调用deployment-controller控制器创建ReplicaSet yaml并写入etcd数据库
- ReplicaSet controller根据该ReplicaSet yaml向k8s apiserver请求创建pod
- 然后才是scheduler调度资源,kubelet创建pod
所以,Deployment删除之后,ReplicaSet并未删除,还是能让pod处于正常的运行状态。只有将rc、rs、job也删除,才能删除对应的pod。
以上是关于k8s中pod删不掉的主要内容,如果未能解决你的问题,请参考以下文章