k8s 删除几种Terminating 状态的pod

删除

查看Terminating 状态

[[email protected] dashboard]# kubectl  get ns|grep kubernetes-dashboard
kubernetes-dashboard        Terminating   26h
kubernetes-dashboard-head   Terminating   5h57m

[[email protected] dashboard]# kubectl get ns kubernetes-dashboard -o yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Namespace","metadata":{"annotations":{},"name":"kubernetes-dashboard"}}
creationTimestamp: "2020-01-20T06:25:38Z"
deletionTimestamp: "2020-01-21T06:18:30Z"
name: kubernetes-dashboard
resourceVersion: "208494"
selfLink: /api/v1/namespaces/kubernetes-dashboard
uid: 77cae2ea-b0bd-48a3-8070-29e5d56573f5
spec:
finalizers:
- kubernetes
status:
conditions:
- lastTransitionTime: "2020-01-21T06:18:35Z"
message: ‘Discovery failed for some groups, 1 failing: unable to retrieve the
complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently
unable to handle the request‘
reason: DiscoveryFailed
status: "True"
type: NamespaceDeletionDiscoveryFailure
- lastTransitionTime: "2020-01-21T06:18:37Z"
message: All legacy kube types successfully parsed
reason: ParsedGroupVersions
status: "False"
type: NamespaceDeletionGroupVersionParsingFailure
- lastTransitionTime: "2020-01-21T06:18:37Z"
message: All content successfully deleted
reason: ContentDeleted
status: "False"
type: NamespaceDeletionContentFailure
phase: Terminating

查看详情

error: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request
[[email protected] dashboard]# kubectl delete apiservice v1beta1.metrics.k8s.io
apiservice.apiregistration.k8s.io "v1beta1.metrics.k8s.io" deleted

# 查看k8s集群中可以使用命名空间隔离的资源

[[email protected] dashboard]# kubectl api-resources -o name --verbs=list --namespaced | xargs -n 1 kubectl get --show-kind --ignore-not-found -n kubernetes-dashboard
[[email protected] dashboard]#

发现并没有

第一种方式:

[[email protected] dashboard]# kubectl  delete ns kubernetes-dashboard
Error from server (Conflict): Operation cannot be fulfilled on namespaces "kubernetes-dashboard": The system is ensuring all content is removed from this namespace.  Upon completion, this namespace will automatically be purged by the system.

第二种

# 使用强制删除(依然无法删除该命名空间)

[[email protected] dashboard]# kubectl  delete ns kubernetes-dashboard --force --grace-period=0
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
Error from server (NotFound): namespaces "kubernetes-dashboard" not found

使用原生接口删除

# 获取namespace的详情信息

[[email protected] dashboard]# kubectl get ns kubernetes-dashboard -o json > kubernetes-dashboard.json
[[email protected] dashboard]# cat kubernetes-dashboard.json
{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "annotations": {
            "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"kubernetes-dashboard\"}}\n"
        },
        "creationTimestamp": "2020-01-20T06:25:38Z",
        "deletionTimestamp": "2020-01-21T06:18:30Z",
        "name": "kubernetes-dashboard",
        "resourceVersion": "208494",
        "selfLink": "/api/v1/namespaces/kubernetes-dashboard",
        "uid": "77cae2ea-b0bd-48a3-8070-29e5d56573f5"
    },
    "spec": {
        "finalizers": [
            "kubernetes"
        ]
    },
    "status": {
        "conditions": [
            {
                "lastTransitionTime": "2020-01-21T06:18:35Z",
                "message": "Discovery failed for some groups, 1 failing: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request",
                "reason": "DiscoveryFailed",
                "status": "True",
                "type": "NamespaceDeletionDiscoveryFailure"
            },
            {
                "lastTransitionTime": "2020-01-21T06:18:37Z",
                "message": "All legacy kube types successfully parsed",
                "reason": "ParsedGroupVersions",
                "status": "False",
                "type": "NamespaceDeletionGroupVersionParsingFailure"
            },
            {
                "lastTransitionTime": "2020-01-21T06:18:37Z",
                "message": "All content successfully deleted",
                "reason": "ContentDeleted",
                "status": "False",
                "type": "NamespaceDeletionContentFailure"
            }
        ],
        "phase": "Terminating"
    }
}

参考了 https://juejin.im/post/5dada0bc5188253b2f003eff 这个

原文地址:https://www.cnblogs.com/jackluo/p/12222335.html

时间: 2024-11-02 09:15:42

k8s 删除几种Terminating 状态的pod的相关文章

Kubernetes强制删除一直处于Terminating状态的pod。

在dashboard界面删除容器,发现无法删除.使用命令查看发现该pod一直处于terminating的状态Kubernetes强制删除一直处于Terminating状态的pod. 1.使用命令获取pod的名字kubectl get po -n NAMESPACE |grep Terminating2.使用kubectl中的强制删除命令kubectl delete pod podName -n NAMESPACE --force --grace-period=0 原文地址:https://blo

k8s删除pod一直处于terminating状态

用的nfs挂载卷,当删除pv后再删除pod时,pod一直处于terminating状态. 如下图: 解决方法: 可使用kubectl中的强制删除命令 # 删除POD kubectl delete pod [pod name] --force --grace-period=0 -n [namespace] # 删除NAMESPACE kubectl delete namespace NAMESPACENAME --force --grace-period=0 若以上方法无法删除,可使用第二种方法,

Kubernetes删除namespace后持续terminating状态

删除isti和foo的配置文件之后,namespace持续terminating状态,此时也无法再创建istio-system的namespace namespace "istio-system" edited [email protected]:~/istio-0.8.0/install/kubernetes# kubectl get ns NAME STATUS AGE choerodon-devops-prod Active 21d default Active 30d foo

K8S-删除Terminating状态的namespace

kubernetes 删除Terminating状态的命名空间 1.检查该namespace下是否还有资源: kubectl get all --namespace=cattle-system 2.删除资源: kubectl delete pods <pod> --grace-period=0 --force 3.编辑namespace: kubectl edit ns cattle-system 注释掉finalizers部分,保存即会删除该ns 4.查看查看已被删除: kubectl ge

进程三种基本状态

进程的三种基本状态: (1)       就绪状态:进程已获得除CPU外的所有必要资源,只等待CPU时的状态.一个系统会将多个处于就绪状态的进程排成一个就绪队列. (2)       执行状态:进程已获CPU,正在执行.单处理机系统中,处于执行状态的进程只一个:多处理机系统中,有多个处于执行状态的进程. (3)       阻塞状态:正在执行的进程由于某种原因而暂时无法继续执行,便放弃处理机而处于暂停状态,即进程执行受阻.(这种状态又称等待状态或封锁状态) 通常导致进程阻塞的典型事件有:请求I/

ajax中XMLHttpRequest对象中readyState与status的几种常见状态

XMLHttpRequest对象的readyState与status的几种状态码表示的意思: readyState有五种状态: 0 (未初始化): (XMLHttpRequest)对象已经创建,但还没有调用open()方法: 1 (载入):已经调用open() 方法,但尚未发送请求: 2 (载入完成): 请求已经发送完成: 3 (交互):可以接收到部分响应数据: 4 (完成):已经接收到了全部数据,并且连接已经关闭. status实际是一种辅状态判断,只是status更多是服务器方的状态判断.

Hibernate 几种对象状态

Hibernate 中四种对象状态 临时状态(transient):刚用new 语句创建,还没有被持久化,并且不处于Sesssion 的缓存中.处于临时状态 的Java 对象被称为临时对象. 持久化状态(persistent):已经被持久化,并且加入到Session 的缓存中.处于持久化状态的Java 对象被称为 持久化对象. 删除状态(removed):不再处于Session 的缓存中,并且Session 已经计划将其从数据库中删除.处于删除状 态的Java 对象被称为删除对象. 游离状态(d

Java虚拟机15:再谈四种引用状态

JVM的四种引用状态 在Java虚拟机5:Java垃圾回收(GC)机制详解一文中,有简单提到过JVM的四种引用状态,当时只是简单学习,知道有这么一个概念,对四种引用状态理解不深.这两天重看虚拟机这部分的时候,写了很多例子详细研究了一下JVM的几种引用,对于JVM的引用理解加深了不少,因此总结写一篇文章总结并分享下. 首先,还是先从JVM四种引用状态开始,这部分摘抄自周志明老师的<深入理解Java虚拟机:JVM高级特性与最佳实践>一书. 在JDK1.2之前,Java中的引用的定义很传统:如果re

【原创】(IOS开发)highlighted和selected两种按钮状态原理摸索分享

先科普以下常识:简单来看,按钮有点击.非点击2个状态,点击时系统会自动调用设置按钮高亮状态的方法(setHighlighted:):非点击时视为正常状态(normal).我们可以根据需要给不同状态设置不同背景图片,苹果官方对按钮状态细致划分为3种:高亮(highlighted).选中(selected).普通(normal),如果编写代码时调用了方法(setSelected:),按钮会呈选中状态(selected). 3种按钮状态,苹果官方命名为: UIControlStateNorma(正常)