【问题标题】:Deleting namespace was stuck at "Terminating" State删除命名空间卡在“终止”状态
【发布时间】:2020-09-26 03:09:55
【问题描述】:

我想删除在 Kubernetes 中创建的命名空间。 我执行的命令:

kubectl 删除命名空间 devops-ui

但这个过程耗时太长(约 20 分钟)而且还在计数。

在检查 minikube 仪表板时,一个 pod 仍然存在,它没有被删除,它处于终止状态。

有什么办法吗?

【问题讨论】:

    标签: kubernetes namespaces minikube terminate


    【解决方案1】:

    请先使用以下命令删除 pod

    kubectl delete pod  pod_name_here --grace-period=0 --force --namespace devops-ui 
    

    现在删除命名空间

    kubectl delete namespaces devops-ui
    

    【讨论】:

    • 解决方案成功,谢谢
    【解决方案2】:
    1. 删除命名空间时,会触发删除该命名空间内的所有实体
    2. 您可以运行“kubectl get all -n namespace-name”并查看命名空间内所有组件的状态
    3. 理想情况下,最好等待所有 pod 被彻底删除(而不是使用 --grace-period=0 强制删除 pod:这只会删除 pod 的 etcd 记录 - 但相应的容器可能正在运行)

    参考:https://kubernetes.io/docs/tasks/administer-cluster/namespaces/

    【讨论】:

      【解决方案3】:

      一些 CRD 有终结器,这将阻止命名空间终止

      示例从这里开始 https://github.com/kubernetes/kubernetes/issues/60807#issuecomment-408599873

      @ManifoldFR , I had the same issue as yours and I managed to make it work by making an API call with json file .
      kubectl get namespace annoying-namespace-to-delete -o json > tmp.json
      then edit tmp.json and remove"kubernetes"
      
      curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json https://kubernetes-cluster-ip/api/v1/namespaces/annoying-namespace-to-delete/finalize
      
      

      注意 - 使用 https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/ - 如果您正在运行测试集群并需要获取集群 API 访问权限

      在我的情况下,它抛出了持有的资源(在默认命名空间中)

          {
              "type": "NamespaceContentRemaining",
              "status": "True",
              "lastTransitionTime": "2020-10-09T09:35:11Z",
              "reason": "SomeResourcesRemain",
              "message": "Some resources are remaining: cephblockpools.ceph.rook.io has 2 resource instances, cephclusters.ceph.rook.io has 1 resource instances"
            },
            {
              "type": "NamespaceFinalizersRemaining",
              "status": "True",
              "lastTransitionTime": "2020-10-09T09:35:11Z",
              "reason": "SomeFinalizersRemain",
              "message": "Some content in the namespace has finalizers remaining: cephblockpool.ceph.rook.io in 2 resource instances, cephcluster.ceph.rook.io in 1 resource instances"
            }
          ]
      

      【讨论】:

        猜你喜欢
        • 2019-02-21
        • 2019-03-27
        • 2021-04-16
        • 1970-01-01
        • 2023-02-09
        • 2019-09-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多