[K8S] Restoring accidentally deleted Namespace

Hi all!

Recently there was a lot of stuff going on in the world and i didn’t really had any will to post anything, which is a shame. I’ve started to recover K8s in my memory by starting the study process all over again.

And sometime ago we had quite “fun” situation. One of the developers “accidentally” deleted the namespace in their new dev environment.

As me and my colleague needed some study experience we didn’t really want to go with an easy process and just restore the cluster from the last backup point, but we wanted to restore only the namespace.

So first of all we fired up the backup, found out that the namespace and all the deployments are there. We had to comeback few times to our backup as more and more things we needed.

So here is a list of all the items we had to recover:

  1. Service Accounts
  2. Secrets
  3. Roles
  4. Role Bindings
  5. Configuration Maps
  6. Ingress
  7. Deployments
  8. Services

You can simply get this information by running:

kubectl get ‘resource type’ ‘resource name’ -n ‘namespace name’ -o yaml

And apply the manifest by using:

kubectl apply -f ‘file.yml’

That is a short read, but hope it was usefull 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.