<p>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. </p>

<p>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?</p>

<p>Thanks </p>

<p>A few interesting articles about <strong>backing up and restoring <code>Kubernetes cluster</code></strong> using various tools:</p>

<p><a href="https://medium.com/@pmvk/kubernetes-backups-and-recovery-efc33180e89d" rel="nofollow noreferrer">https://medium.com/@pmvk/kubernetes-backups-and-recovery-efc33180e89d</a></p>

<p><a href="https://blog.kubernauts.io/backup-and-restore-of-kubernetes-applications-using-heptios-velero-with-restic-and-rook-ceph-as-2e8df15b1487" rel="nofollow noreferrer">https://blog.kubernauts.io/backup-and-restore-of-kubernetes-applications-using-heptios-velero-with-restic-and-rook-ceph-as-2e8df15b1487</a></p>

<p><a href="https://www.digitalocean.com/community/tutorials/how-to-back-up-and-restore-a-kubernetes-cluster-on-digitalocean-using-heptio-ark" rel="nofollow noreferrer">https://www.digitalocean.com/community/tutorials/how-to-back-up-and-restore-a-kubernetes-cluster-on-digitalocean-using-heptio-ark</a></p>

<p><a href="https://www.revolgy.com/blog/kubernetes-in-production-snapshotting-cluster-state" rel="nofollow noreferrer">https://www.revolgy.com/blog/kubernetes-in-production-snapshotting-cluster-state</a></p>

<p>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.</p>

<p>Please notice that in all of those articles they use <code>namespace deletion</code> to <strong>simulate disaster scenario</strong> 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 <strong>namespace deletion</strong> <em>removes all kubernetes cluster resources in a given namespace</em> including <code>LoadBalancers</code> or <code>PersistentVolumes</code>. It may take some time. Some resource may not be deleted because it is still used by another resource (e.g. <code>PersistentVolume</code> by running <code>Pod</code>).</p>

<p>You can try and run <a href="https://gist.github.com/negz/c3ee465b48306593f16c523a22015bec" rel="nofollow noreferrer">this</a> 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 <code>--all-namespaces</code> flag to list them.</p>

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

<pre><code>kubectl get deployment nginx-deployment -o yaml &gt; deployment_backup.yaml
</code></pre>

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