Can i get deleted network policies on namespace?

Viewed 24

I need to find out the history of network policies on a namespace. kubectl get networkpolicy shows only available ones.

Is there any command that I can see deleted network policies?

1 Answers

This answer is not limited to network policies. In the Kubernetes cluster, if you want to see the logs for any resource creation, update, or deletion, you can find them in the audit logs. You can read more about audit logs here.

Note/Limitations:

  1. Audit logs are already enabled in most real clusters after creation. However, for many test(hello world) clusters, you need to enable them.
  2. Not all users have access to view the audit logs.
  3. If the audit logs aren't enabled for a resource type(in your case, network policy), you cannot obtain the details.
  4. Like any other logs, audit logs also rotate, so if you are trying to find details of some event that happened way back then, the logs will be lost due to rotation.
Related