kubernetes Pod保持在终止的EC2示例上终止

dwbf0jvd  于 2023-01-16  发布在  Kubernetes
关注(0)|答案(2)|浏览(136)

我已经在AWS平台中创建了Kubernetes集群,并使用DaemonSets创建Pod。
示例终止后,对应的pod仍处于Terminating状态。
有没有人想在kubernetes master中清理这样的Terminating pod?

zkure5ic

zkure5ic1#

您可以通过提供kubectl delete pod NAME --grace-period=0强制删除pod,也可以使用kubectl delete node NAME删除节点(如果您不打算将其恢复),pod应该会得到清理。

nx7onnlm

nx7onnlm2#

用终端盒结束的通常方式是:

kubectl delete pod -n ${namespace} ${pod} --grace-period=0

但您可能需要删除终结器,因为终结器可能会阻止POD使用以下命令停止:

kubectl -n ${namespace} patch pod ${pod} -p '{"metadata":{"finalizers":null}}'

如果这些都不起作用,您可以使用etcdctl从etcd中删除pod:

# Define variables
ETCDCTL_API=3
certs-path=${HOME}/.certs/e
etcd-cert-path=${certs-path}/etcd.crt
etcd-key-path=${certs-path}/etcd.key
etcd-cacert-path=${certs-path}/etcd.ca
etcd-endpoints=https://127.0.0.1:2379
namespace=myns
pod=mypod

# Call etcdctl to remove the pod
etcdctl del \
--endpoints=${etcd-endpoints}\
--cert ${etcd-cert-path} \
--key ${etcd-client-key}\
--cacert ${etcd-cacert-path} \
--prefix \
/registry/pods/${namespace}/${pod}

相关问题