This is a cache of https://docs.okd.io/4.17/networking/network_security/network_policy/deleting-network-policy.html. It is a snapshot of the page at 2025-08-24T00:31:46.961+0000.
Deleting a network policy - Network security | Networking | OKD 4.17
×

As a user with the admin role, you can delete a network policy from a namespace.

Deleting a network policy using the CLI

You can delete a network policy in a namespace.

If you log in with a user with the cluster-admin role, then you can delete any network policy in the cluster.

Prerequisites
  • Your cluster uses a network plugin that supports NetworkPolicy objects, such as the OVN-Kubernetes network plugin, with mode: NetworkPolicy set.

  • You installed the OpenShift CLI (oc).

  • You logged in to the cluster with a user with admin privileges.

  • You are working in the namespace where the network policy exists.

Procedure
  • To delete a network policy object, enter the following command:

    $ oc delete networkpolicy <policy_name> -n <namespace>

    where:

    <policy_name>

    Specifies the name of the network policy.

    <namespace>

    Optional parameter. If you defined the object in a different namespace than the current namespace, the parameter specifices the namespace.

    Successful output lists the name of the policy object and the deleted status.

If you log in to the web console with cluster-admin privileges, you have a choice of deleting a network policy in any namespace in the cluster directly in YAML or from the policy in the web console through the Actions menu.