首页 > 其他分享 >强制删除namespace

强制删除namespace

时间:2023-07-25 13:00:34浏览次数:25  
标签:kubectl monitoring 删除 master01 namespace 2023 强制 k8s root

之前部署过一套监控

因为是本地测试环境,资源不太够,想着进行删除命名空间monitoring

[root@k8s-master01 ]# kubectl delete ns monitoring
namespace "monitoring" deleted
^C
[root@k8s-master01 ]# kubectl delete ns monitoring
namespace "monitoring" deleted
^C
[root@k8s-master01 ]# kubectl delete ns monitoring --force
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.
namespace "monitoring" force deleted
^C

一直删除不掉

解决办法

强制删除

[root@k8s-master01 ~]# kubectl get namespace monitoring -o json > monitoring.json

删除这几行

删除后

启动 运行kube-proxy

[root@k8s-master01 sonarqube]# kubectl proxy
Starting to serve on 127.0.0.1:8001
窗口不能关闭

通过API执行强制删除操作

[root@k8s-master01 ~]# curl -k -H "Content-Type: application/json" -X PUT --data-binary @monitoring.json http://127.0.0.1:8001/api/v1/namespaces/monitoring/finalize
{
  "kind": "Namespace",
  "apiVersion": "v1",
  "metadata": {
    "name": "monitoring",
    "uid": "37ab45a2-fbb9-4162-80f5-8e9957cd833f",
    "resourceVersion": "3147665",
    "creationTimestamp": "2023-03-15T14:47:22Z",
    "deletionTimestamp": "2023-07-24T16:45:36Z",
    "labels": {
      "kubernetes.io/metadata.name": "monitoring"
    }
  },
  "spec": {},
  "status": {
    "phase": "Terminating",
    "conditions": [
      {
        "type": "NamespaceDeletionDiscoveryFailure",
        "status": "True",
        "lastTransitionTime": "2023-07-24T16:45:49Z",
        "reason": "DiscoveryFailed",
        "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"
      },
      {
        "type": "NamespaceDeletionGroupVersionParsingFailure",
        "status": "False",
        "lastTransitionTime": "2023-07-24T16:45:43Z",
        "reason": "ParsedGroupVersions",
        "message": "All legacy kube types successfully parsed"
      },
      {
        "type": "NamespaceDeletionContentFailure",
        "status": "False",
        "lastTransitionTime": "2023-07-24T16:45:43Z",
        "reason": "ContentDeleted",
        "message": "All content successfully deleted, may be waiting on finalization"
      },
      {
        "type": "NamespaceContentRemaining",
        "status": "False",
        "lastTransitionTime": "2023-07-24T16:45:52Z",
        "reason": "ContentRemoved",
        "message": "All content successfully removed"
      },
      {
        "type": "NamespaceFinalizersRemaining",
        "status": "False",
        "lastTransitionTime": "2023-07-24T16:45:43Z",
        "reason": "ContentHasNoFinalizers",
        "message": "All content-preserving finalizers finished"
      }
    ]
  }
}

再次删除测试
[root@k8s-master01 sonarqube]# kubectl delete ns monitoring 
Error from server (NotFound): namespaces "monitoring" not found

可以看到已经进行删除
[root@k8s-master01 sonarqube]# kubectl get ns -A | grep monitoring
[root@k8s-master01 sonarqube]# 

标签:kubectl,monitoring,删除,master01,namespace,2023,强制,k8s,root
From: https://www.cnblogs.com/chuyiwang/p/17579632.html

相关文章

  • 【python】删除字符串中以\x开头的特殊字符
    1、场景  paramiko获取的字符串中有很多\x开头的字符,需要去除,获取原始输出  2、处理方法content="\x071cd\0x70"#使用unicode-escape编码集,将unicode内存编码值直接存储,并替换空白字符content=content.encode('unicode_escape').decode('utf-8').replace('','......
  • docker停止所有容器并删除
    要停止并删除所有容器,可以使用以下命令:停止所有容器:dockerstop$(dockerps-aq)该命令将停止所有正在运行中的容器。删除所有容器:dockerrm$(dockerps-aq)该命令将删除所有容器,包括已停止的容器。请注意,这些命令会立即停止和删除所有容器,因此请在使用之前确保您......
  • int强制转换char在Java中的使用方法
    int强制转换char在Java中的使用方法在Java编程中,我们经常需要进行数据类型的转换,以便满足不同的需求。其中一个常见的转换就是将int类型强制转换为char类型。本文将围绕这一主题,介绍int强制转换char的使用方法,并探讨一些相关的注意事项。首先,让我们来看一下int和char的基本概念......
  • notepad如何删除某个字符开头的行,notepad如何删除空白行(好文转发)
    notepad如何删除某个字符开头的行^#.*$   注意:#替换成你想要删除行中的字符就可 notepad如何删除空白行 转发:https://blog.csdn.net/qq_34412985/article/details/107428206原作者:qq_34412985(多谢作者提供好文)......
  • 浏览器取消强制访问HTTPS
    浏览器开启https重定向,但是你访问的网页默认不能够进行https访问,只可以访问http,那么就需要取消浏览器的默认转发请求谷歌浏览器:chrome://net-internals/#hstsEdge浏览器:edge://net-internals/#hsts......
  • k8s中删除节点之后再添加节点
    删除节点先标记为不可调度,驱逐节点上的pod#先标记节点$kubectldraincentos7909--delete-emptydir-data--force--ignore-daemonsetsnode/centos7909alreadycordonedWARNING:ignoringDaemonSet-managedPods:kube-flannel/kube-flannel-ds-hnmmg,kube-system/kube......
  • ORACLE空间管理实验5:块管理之ASSM下高水位的影响--删除和查询
    高水位概念:所有的oracle段(segments,在此,为了理解方便,建议把segment作为表的一个同义词)都有一个在段内容纳数据的上限,我们把这个上限称为"highwatermark"或HWM。这个HWM是一个标记,用来说明已经有多少没有使用的数据块分配给这个segment。HWM原则上HWM只......
  • MongoDB 教程二: 添加, 删除,查询 shell命令
       MongoDBShell常用操作命令MonoDB shell命令操作语法和JavaScript很类似,其实控制台底层的查询语句都是用JavaScript脚本完成操作的。 Ø数据库//1、Help查看命令提示helpdb.help();db.yourColl.help();db.youColl.find().help();rs.help();//2、切换/创建......
  • linux sh 脚本:备份文件及删除十天以前的备份文件
     #如果文件夹不存在,创建文件夹if[!-d"/www/backup/data"];thenmkdir/www/backup/ant-datafi#切换目录cd/usr/#开始打包备份tar-zcvf/www/backup/data/data-$(date+%Y%m%d).tar.gzdata#移除十天以前的备份文件包find/www/backup/data/-mtime+10-n......
  • 在Linux添加定时任务删除5天前的日志文件
    在Linux添加定时任务删除5天前的日志文件利用shell脚本自动清理1.删除文件命令:find对应目录-mtime+天数-name"文件名"-execrm-f{}\;实例命令:find/usr/local/mysql/logs-typef-mtime+5-name"*.txt"-execrm-f{}\;说明:将/usr/local/mysql/logs目录下所......