kubernetes-pods状态分析【kubernetes pod Terminating】

    技术2025-02-17  19

    这里写目录标题

    知识回顾pods状态分析【Terminating】其他方法知其然知其所以然

    知识回顾

    POD的生命周期状态如下 状态机状态解释

    pods状态分析【Terminating】

    在试验中删除pods资源,发现一直在hang的状态,于是查看状态

    # kubectl get pods NAME READY STATUS RESTARTS AGE pod-vol-pvc 0/1 Terminating 0 44h

    可以强制删除

    kubectl delete pods pod-vol-pvc --force

    其他方法

    存在Node节点内核出现bug,导致状态异常,重启node

    如果force无法删除,可以采用云原生接口删除

    方法引用地址:k8s 删除几种Terminating 状态的pod

    # 获取namespace的详情信息 $ kubectl get ns rdbms -o json > rdbms.json # 查看napespace定义的json配置 ## 删除掉spec部分即可 $ cat rdbms.json { "apiVersion": "v1", "kind": "Namespace", "metadata": { "annotations": { "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"rdbms\"}}\n" }, "creationTimestamp": "2019-10-14T12:17:44Z", "deletionTimestamp": "2019-10-14T12:30:27Z", "name": "rdbms", "resourceVersion": "8844754", "selfLink": "/api/v1/namespaces/rdbms", "uid": "29067ddf-56d7-4cce-afa3-1fbdbb221ab1" }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Terminating" } } # 使用http接口进行删除 $ curl -k -H "Content-Type:application/json" -X PUT --data-binary @rdbms.json https://x.x.x.x:6443/api/v1/namespaces/rdbms/finalize { "kind": "Namespace", "apiVersion": "v1", "metadata": { "name": "rdbms", "selfLink": "/api/v1/namespaces/rdbms/finalize", "uid": "29067ddf-56d7-4cce-afa3-1fbdbb221ab1", "resourceVersion": "8844754", "creationTimestamp": "2019-10-14T12:17:44Z", "deletionTimestamp": "2019-10-14T12:30:27Z", "annotations": { "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"rdbms\"}}\n" } }, "spec": { }, "status": { "phase": "Terminating" } # 再次查看namespace发现已经被删除了 $ kubectl get ns | grep rdb

    知其然知其所以然

    官方文档

    Processed: 0.011, SQL: 9