意外删除的Kubernetes命名空间 [英] Accidentally deleted Kubernetes namespace

查看:396
本文介绍了意外删除的Kubernetes命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google云上有一个Kubernetes集群.我不小心删除了其中运行了几个Pod的命名空间.幸运的是,pod仍在运行,但是名称空间处于终止状态.

I have a Kubernetes cluster on google cloud. I accidentally deleted a namespace which had a few pods running in it. Luckily, the pods are still running, but the namespace is in terminations state.

是否有办法将其恢复为活动状态?如果没有,那么在此命名空间中运行的吊舱的命运将如何?

Is there a way to restore it back to active state? If not, what would the fate of my pods running in this namespace be?

谢谢

推荐答案

一些有关使用各种工具备份和还原Kubernetes cluster 的有趣文章:

A few interesting articles about backing up and restoring Kubernetes cluster using various tools:

https://medium.com/@pmvk/kubernetes-backups -and-recovery-efc33180e89d

https://blog.kubernauts.io/backup-and-restore-of-kubernetes-applications-using-heptios-velero-with-restic-and-rook-ceph-as-2e8df15b1487

https://www.digitalocean.com/community/tutorials/how-to-back-up-and-restore-a-kubernetes-cluster-on-digitalocean-using-heptio-ark

https://www.revolgy.com/blog /kubernetes-in-production-snapshotting-集群状态

我想它们可能会有用,而不是将来而不是在您当前的情况下.如果您没有任何备份,那么您将无能为力.

I guess they may be useful rather in future than in your current situation. If you don't have any backup, unfortunately there isn't much you can do.

请注意,在所有这些文章中,他们使用namespace deletion模拟灾难情况,因此您可以想象这种操作的后果是什么.但是,结果可能不会立即显示,您可能会看到Pod运行了一段时间,但最终命名空间删除 删除了给定命名空间中的所有kubernetes集群资源 ,包括LoadBalancersPersistentVolumes.可能需要一些时间.某些资源可能仍被另一资源使用(例如,通过运行PodPersistentVolume),因此可能无法删除某些资源.

Please notice that in all of those articles they use namespace deletion to simulate disaster scenario so you can imagine what are the consequences of such operation. However the results may not be seen immediately and you may see your pods running for some time but eventually namespace deletion removes all kubernetes cluster resources in a given namespace including LoadBalancers or PersistentVolumes. It may take some time. Some resource may not be deleted because it is still used by another resource (e.g. PersistentVolume by running Pod).

您可以尝试运行脚本来转储所有仍可用于的资源yaml文件,但是可能需要进行一些修改,因为您将无法再列出属于已删除名称空间的对象.您可能需要添加--all-namespaces标志以列出它们.

You can try and run this script to dump all your resources that are still available to yaml files however some modification may be needed as you will not be able to list objects belonging to deleted namespace anymore. You may need to add --all-namespaces flag to list them.

您也可以尝试转储仍然手动可用的任何资源.如果仍然可以看到PodsDeployments等资源,并且可以在它们上运行kubectl get,则可以尝试将其定义保存到yaml文件中:

You may also try to dump any resource which is still available manually. If you still can see some resources like Pods, Deployments etc. and you can run on them kubectl get you may try to save their definition to a yaml file:

kubectl get deployment nginx-deployment -o yaml > deployment_backup.yaml

一旦备份了资源,您应该能够更轻松地重新创建集群.

Once you have your resources backed up you should be able to recreate your cluster more easily.

这篇关于意外删除的Kubernetes命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆