1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 15:46:57 +01:00
Files
openshift-docs/modules/nw-networkpolicy-delete-cli.adoc
2022-09-02 19:48:06 +00:00

84 lines
2.1 KiB
Plaintext

// Module included in the following assemblies:
//
// * networking/network_policy/deleting-network-policy.adoc
// * post_installation_configuration/network-configuration.adoc
:name: network
:role: admin
ifeval::[{product-version} >= 4.6]
:ovn:
endif::[]
ifeval::["{context}" == "configuring-multi-network-policy"]
:multi:
:name: multi-network
:role: cluster-admin
endif::[]
:_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[]
[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[]
.Prerequisites
* Your cluster uses a cluster network provider that supports `NetworkPolicy` objects, such as
ifndef::ovn[]
the OpenShift SDN network provider with `mode: NetworkPolicy` set.
endif::ovn[]
ifdef::ovn[]
the OVN-Kubernetes network provider or the OpenShift SDN network provider with `mode: NetworkPolicy` set.
endif::ovn[]
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 `{role}` privileges.
* 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 <policy_name> -n <namespace>
----
+
--
where:
`<policy_name>`:: Specifies the name of the {name} policy.
`<namespace>`:: 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::ovn[]
:!ovn:
endif::ovn[]
ifdef::multi[]
:!multi:
endif::multi[]
:!name:
:!role:
[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.
====