// Module included in the following assemblies: // // * networking/network_policy/deleting-network-policy.adoc // * networking/multiple_networks/configuring-multi-network-policy.adoc // * microshift_networking/microshift-network-policy/microshift-editing-network-policy.adoc :name: network :role: admin ifeval::["{context}" == "configuring-multi-network-policy"] :multi: :name: multi-network :role: cluster-admin endif::[] :_mod-docs-content-type: PROCEDURE [id="nw-networkpolicy-delete-cli_{context}"] = Deleting a {name} policy using the CLI You can delete a {name} policy in a namespace. ifndef::multi,microshift[] [NOTE] ==== If you log in with a user with the `cluster-admin` role, then you can delete any network policy in the cluster. ==== endif::multi,microshift[] .Prerequisites ifndef::microshift[] * Your cluster uses a network plugin that supports `NetworkPolicy` objects, such as the OVN-Kubernetes network plugin or the OpenShift SDN network plugin with `mode: NetworkPolicy` set. This mode is the default for OpenShift SDN. endif::microshift[] * You installed the OpenShift CLI (`oc`). ifndef::microshift[] * You are logged in to the cluster with a user with `{role}` privileges. endif::microshift[] * You are working in the namespace where the {name} policy exists. .Procedure * To delete a {name} policy object, enter the following command: + [source,terminal,subs="attributes+"] ---- $ oc delete {name}policy -n ---- + -- where: ``:: Specifies the name of the {name} policy. ``:: Optional: Specifies the namespace if the object is defined in a different namespace than the current namespace. -- + .Example output [source,text] ---- ifndef::multi[] networkpolicy.networking.k8s.io/default-deny deleted endif::multi[] ifdef::multi[] multinetworkpolicy.k8s.cni.cncf.io/default-deny deleted endif::multi[] ---- ifdef::multi[] :!multi: endif::multi[] :!name: :!role: ifndef::microshift[] [NOTE] ==== 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. ==== endif::microshift[]