What is the reverse of "kubectl apply"?

8/27/2019

I was playing around in minikube and installed the wrong version of istio. I ran:

kubectl apply -f install/kubernetes/istio-demo-auth.yaml

instead of:

kubectl apply -f install/kubernetes/istio-demo.yaml

I figured I would just undo it and install the right one.

But I cannot seem to find an unapply command.

How do I undo a "kubectl apply" command?

-- Vaccano
kubernetes

1 Answer

8/27/2019

One way would be kubectl delete -f <filename> but it implies few things:

  1. The resources were first created. It simply removes all of those, if you really want to "revert to the previous state" I'm not sure there are built-in tools in Kubernetes to do that (so you really would restore from a backup, if you have one)

  2. The containers did not modify the host machines: containers may mount root filesystem and change it, or kernel subsystems (iptables, etc). The delete command would not revert it either, and in that case you really need to check the documentation for the product to see if they offer any official way to guarantees a proper cleanup

-- zerkms
Source: StackOverflow