1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00
Files
openshift-docs/modules/nw-networkpolicy-edit.adoc
2020-09-08 20:23:19 +00:00

56 lines
1.8 KiB
Plaintext

// Module included in the following assemblies:
//
// * networking/network_policy/editing-network-policy.adoc
[id="nw-networkpolicy-edit_{context}"]
= Editing a NetworkPolicy object
You can edit a NetworkPolicy object in a namespace.
.Prerequisites
* Your cluster is using a default CNI network provider that supports NetworkPolicy objects, such as 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 `cluster-admin` privileges.
.Procedure
. Optional: List the current NetworkPolicy objects.
.. If you want to list the policy objects in a specific namespace, enter the following command. Replace `<namespace>` with the namespace for a project.
+
[source,terminal]
----
$ oc get networkpolicy -n <namespace>
----
.. If you want to list the policy objects for the entire cluster, enter the following command:
+
[source,terminal]
----
$ oc get networkpolicy --all-namespaces
----
. Edit the NetworkPolicy object.
.. If you saved the NetworkPolicy in a file, edit the file and make any necessary changes, and then enter the following command. Replace `<policy-file>` with the name of the file containing the object definition.
+
[source,terminal]
----
$ oc apply -f <policy-file>.yaml
----
.. If you need to update the NetworkPolicy object directly, you can enter the following command. Replace `<policy-name>` with the name of the NetworkPolicy object and `<namespace>` with the name of the project where the object exists.
+
[source,terminal]
----
$ oc edit <policy-name> -n <namespace>
----
. Confirm that the NetworkPolicy object is updated. Replace `<namespace>` with the name of the project where the object exists.
+
[source,terminal]
----
$ oc get networkpolicy -n <namespace> -o yaml
----