This is a cache of https://docs.openshift.com/container-platform/4.7/networking/network_policy/deleting-network-policy.html. It is a snapshot of the page at 2024-11-27T21:55:51.121+0000.
Deleting a network policy - Network policy | Networking | OpenShift Container Platform 4.7
×

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

Deleting a network policy

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 cluster network provider that supports NetworkPolicy objects, such as the OVN-Kubernetes network provider or the OpenShift SDN network provider with mode: NetworkPolicy set. This mode is the default for OpenShift SDN.

  • You installed the OpenShift CLI (oc).

  • You are 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 NetworkPolicy object, enter the following command:

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

    where:

    <policy_name>

    Specifies the name of the network policy.

    <namespace>

    Optional: Specifies the namespace if the object is defined in a different namespace than the current namespace.

    Example output
    networkpolicy.networking.k8s.io/allow-same-namespace deleted