From b625847219eab9659445ccbb24de7a397a5b8866 Mon Sep 17 00:00:00 2001 From: faweizhao26 Date: Mon, 28 Mar 2022 16:45:36 +0800 Subject: [PATCH] add new blog Signed-off-by: faweizhao26 --- content/zh/blogs/kubekey-v2.0.0-release.md | 2 +- .../blogs/kubesphere-terminating-namespace.md | 426 ++++++++++++++++++ .../images/live/cloudnative-live-banner.png | Bin 276373 -> 276373 bytes 3 files changed, 427 insertions(+), 1 deletion(-) create mode 100644 content/zh/blogs/kubesphere-terminating-namespace.md diff --git a/content/zh/blogs/kubekey-v2.0.0-release.md b/content/zh/blogs/kubekey-v2.0.0-release.md index 1e3631c5b..1fb51efe6 100644 --- a/content/zh/blogs/kubekey-v2.0.0-release.md +++ b/content/zh/blogs/kubekey-v2.0.0-release.md @@ -5,7 +5,7 @@ keywords: 'Kubernetes, KubeSphere, KubeKey, 离线部署, 新版本发布' description: 'KubeKey 2.0.0 正式发布,该版本新增了清单(manifest)和制品(artifact)的概念,为用户离线部署 Kubernetes 集群提供了解决方案。' createTime: '2022-03-12' author: '李耀宗' -snapshot: 'https://pek3b.qingstor.com/kubesphere-community/images/kasten-k10-cover.png' +snapshot: 'https://pek3b.qingstor.com/kubesphere-community/images/KubeKey-v2.0.0-release-cover.png' --- 2022 年 3 月 8 日,KubeKey 2.0.0 正式发布,这是 KubeKey 的第 7 个正式版本,也是非常重要的一个版本。该版本新增了清单(manifest)和制品(artifact)的概念,为用户离线部署 Kubernetes 集群提供了解决方案。 diff --git a/content/zh/blogs/kubesphere-terminating-namespace.md b/content/zh/blogs/kubesphere-terminating-namespace.md new file mode 100644 index 000000000..af302b64b --- /dev/null +++ b/content/zh/blogs/kubesphere-terminating-namespace.md @@ -0,0 +1,426 @@ +--- +title: '删除 KubeSphere 中一直卡在 Terminating 的 Namespace' +tag: 'KubeSphere' +keywords: 'Kubernetes, KubeSphere, Terminating, Namespace ' +description: '本文是删除 KubeSphere 中一直卡在 Terminating 的 Namespace 的实操过程。' +createTime: '2022-02-23' +author: '雪文龙' +snapshot: 'https://pek3b.qingstor.com/kubesphere-community/images/eks-terminating-namespace.png' +--- + +## 介绍 + +最近一直在玩 EKS(Elastic Kubernetes Service -- Amazon EKS) 和 KubeSphere。 因为之前没有使用过 EKS 和 KubeSphere,所以这个过程也是一个试错的过程,在我使用 KubeSphere 的时候发现有一个日志服务,在好奇心的驱使下,我创建了它。 + +在我创建了日志服务(KubeSphere Logging System)以后,我发现我并不想使用它。(可能我只是想看看它到底是什么吧。)强迫症的我就想把它给删除掉。于是我在我的 EKS 中对他进行了强制删除: + +```bash +$ kubectl delete ns kubesphere-logging-system --force --grace-period=0 +``` + +让人尴尬的是,这个 Namespace 并没有立马删除,我自我安慰道,可能 Namespace 下边有其他没有删除的资源在等待删除,我再等等。。。 + +过了半个小时,再次查看删除进度: + +```bash +$ kubectl get ns kubesphere-logging-system +NAME STATUS AGE +kubesphere-logging-system Terminating 6d19h +``` + +它好像这地卡在了 Terminating 的状态。我试着寻找解决方法,参考这个 issue: http://github.com/kubernetes/kubernetes/issues/60807。但是这种方法要通过 API 才可以实现。EKS 是托管在 AWS 中的,我根本没有办法去操作 EKS 的后台。 + +终于我在这个 issue 中找到了答案: https://github.com/kubernetes/kubernetes/issues/60807#issuecomment-663853215 + +## 如何彻底删除 namespace + +### 获取 namespace 的详情信息并转为 json + +```bash +$ kubectl get namespace kubesphere-logging-system -o json > kubesphere-logging-system.json +``` + +### 打开 json 文件编辑 + +```json +{ + "apiVersion": "v1", + "kind": "Namespace", + "metadata": { + "creationTimestamp": "2021-12-31T05:03:58Z", + "deletionTimestamp": "2022-01-05T08:05:40Z", + "labels": { + "kubesphere.io/namespace": "kubesphere-logging-system", + "kubesphere.io/workspace": "system-workspace" + }, + "managedFields": [ + { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + ".": {}, + "f:kubesphere.io/namespace": {} + }, + "f:ownerReferences": { + ".": {}, + "k:{\"uid\":\"6d535470-2592-4f3c-a155-eabc362c339d\"}": { + ".": {}, + "f:apiVersion": {}, + "f:blockOwnerDeletion": {}, + "f:controller": {}, + "f:kind": {}, + "f:name": {}, + "f:uid": {} + } + } + } + }, + "manager": "controller-manager", + "operation": "Update", + "time": "2021-12-31T05:04:01Z" + }, + { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + "f:kubesphere.io/workspace": {} + } + }, + "f:status": { + "f:phase": {} + } + }, + "manager": "kubectl", + "operation": "Update", + "time": "2021-12-31T05:04:01Z" + }, + { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:conditions": { + ".": {}, + "k:{\"type\":\"NamespaceContentRemaining\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceDeletionContentFailure\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceDeletionDiscoveryFailure\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceDeletionGroupVersionParsingFailure\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceFinalizersRemaining\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + } + } + } + }, + "manager": "kube-controller-manager", + "operation": "Update", + "time": "2022-01-05T08:05:47Z" + } + ], + "name": "kubesphere-logging-system", + "ownerReferences": [ + { + "apiVersion": "tenant.kubesphere.io/v1alpha1", + "blockOwnerDeletion": true, + "controller": true, + "kind": "Workspace", + "name": "system-workspace", + "uid": "6d535470-2592-4f3c-a155-eabc362c339d" + } + ], + "resourceVersion": "7376520", + "uid": "2b76e9b1-75f2-4a2e-a819-73b36aea188e" + }, + "spec": { + "finalizers": [ + "kubernetes" # 将此行删除 + ] + }, + "status": { + "conditions": [ + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "All resources successfully discovered", + "reason": "ResourcesDiscovered", + "status": "False", + "type": "NamespaceDeletionDiscoveryFailure" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "All legacy kube types successfully parsed", + "reason": "ParsedGroupVersions", + "status": "False", + "type": "NamespaceDeletionGroupVersionParsingFailure" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "All content successfully deleted, may be waiting on finalization", + "reason": "ContentDeleted", + "status": "False", + "type": "NamespaceDeletionContentFailure" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "Some resources are remaining: fluentbits.logging.kubesphere.io has 1 resource instances", + "reason": "SomeResourcesRemain", + "status": "True", + "type": "NamespaceContentRemaining" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "Some content in the namespace has finalizers remaining: fluentbit.logging.kubesphere.io in 1 resource instances", + "reason": "SomeFinalizersRemain", + "status": "True", + "type": "NamespaceFinalizersRemaining" + } + ], + "phase": "Terminating" + } +} +``` + +找到 spec 将 finalizers 下的 kubernetes 删除。 + +具体如下 + +```json +{ + "apiVersion": "v1", + "kind": "Namespace", + "metadata": { + "creationTimestamp": "2021-12-31T05:03:58Z", + "deletionTimestamp": "2022-01-05T08:05:40Z", + "labels": { + "kubesphere.io/namespace": "kubesphere-logging-system", + "kubesphere.io/workspace": "system-workspace" + }, + "managedFields": [ + { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + ".": {}, + "f:kubesphere.io/namespace": {} + }, + "f:ownerReferences": { + ".": {}, + "k:{\"uid\":\"6d535470-2592-4f3c-a155-eabc362c339d\"}": { + ".": {}, + "f:apiVersion": {}, + "f:blockOwnerDeletion": {}, + "f:controller": {}, + "f:kind": {}, + "f:name": {}, + "f:uid": {} + } + } + } + }, + "manager": "controller-manager", + "operation": "Update", + "time": "2021-12-31T05:04:01Z" + }, + { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + "f:kubesphere.io/workspace": {} + } + }, + "f:status": { + "f:phase": {} + } + }, + "manager": "kubectl", + "operation": "Update", + "time": "2021-12-31T05:04:01Z" + }, + { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:conditions": { + ".": {}, + "k:{\"type\":\"NamespaceContentRemaining\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceDeletionContentFailure\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceDeletionDiscoveryFailure\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceDeletionGroupVersionParsingFailure\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"NamespaceFinalizersRemaining\"}": { + ".": {}, + "f:lastTransitionTime": {}, + "f:message": {}, + "f:reason": {}, + "f:status": {}, + "f:type": {} + } + } + } + }, + "manager": "kube-controller-manager", + "operation": "Update", + "time": "2022-01-05T08:05:47Z" + } + ], + "name": "kubesphere-logging-system", + "ownerReferences": [ + { + "apiVersion": "tenant.kubesphere.io/v1alpha1", + "blockOwnerDeletion": true, + "controller": true, + "kind": "Workspace", + "name": "system-workspace", + "uid": "6d535470-2592-4f3c-a155-eabc362c339d" + } + ], + "resourceVersion": "7376520", + "uid": "2b76e9b1-75f2-4a2e-a819-73b36aea188e" + }, + "spec": { + "finalizers": [ + ] + }, + "status": { + "conditions": [ + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "All resources successfully discovered", + "reason": "ResourcesDiscovered", + "status": "False", + "type": "NamespaceDeletionDiscoveryFailure" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "All legacy kube types successfully parsed", + "reason": "ParsedGroupVersions", + "status": "False", + "type": "NamespaceDeletionGroupVersionParsingFailure" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "All content successfully deleted, may be waiting on finalization", + "reason": "ContentDeleted", + "status": "False", + "type": "NamespaceDeletionContentFailure" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "Some resources are remaining: fluentbits.logging.kubesphere.io has 1 resource instances", + "reason": "SomeResourcesRemain", + "status": "True", + "type": "NamespaceContentRemaining" + }, + { + "lastTransitionTime": "2022-01-05T08:05:47Z", + "message": "Some content in the namespace has finalizers remaining: fluentbit.logging.kubesphere.io in 1 resource instances", + "reason": "SomeFinalizersRemain", + "status": "True", + "type": "NamespaceFinalizersRemaining" + } + ], + "phase": "Terminating" + } +} +``` + +### 执行清理命令 + +现在我们只需要一条命令,就可以彻底删除这个 Namespace。 + +```bash + $ kubectl replace --raw "/api/v1/namespaces/kubesphere-logging-system/finalize" -f ./kubesphere-logging-system.json +``` + +执行完以后,你需要等待一会,再次执行命令检查 Namespace。 + +```bash + $ kubectl replace --raw "/api/v1/namespaces/kubesphere-logging-system/finalize" -f ./kubesphere-logging-system.json +``` + +## 最后的检查 + +``` bash +$ kubectl get ns kubesphere-logging-system +Error from server (NotFound): namespaces "kubesphere-logging-system" not found + +$ kubectl get ns +NAME STATUS AGE +default Active 23d +kubesphere-controls-system Active 9d +kubesphere-devops-system Active 9d +kubesphere-devops-worker Active 16h +kubesphere-monitoring-federated Active 9d +kubesphere-monitoring-system Active 9d +kubesphere-sample-dev Active 8d +kubesphere-system Active 9d +``` + +再次查看的时候,它已经不存在了。 \ No newline at end of file diff --git a/static/images/live/cloudnative-live-banner.png b/static/images/live/cloudnative-live-banner.png index 529d1515884d9cbd91963c42fff490098a4c2c8f..3acf114de6664e5e2c525edaf4e1ae4a854c5096 100644 GIT binary patch delta 83 zcmbRGUSR5bfeo7(87(GnVN_K~PE0g6F-T0(H8)Bz)-^FQvCy?hGO*N5GPkfyHcT=G kN||r|%Q%6FWzy%QQ_T}u+9$Fw0x=U1GjE^B!op$<0E-J6u>b%7 delta 83 zcmbRGUSR5bfeo7(84V_HVN_MIOffb~Hb^qkH8D2<5{U+8x=E(S#=0q%i6-X8CWeX0 j2Bw?;GEQJ(@!PkUr+Fev`$QH-AZ7w$=Is+%SXhh!Q=u6i