mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-07 00:48:01 +01:00
107 lines
3.0 KiB
Plaintext
107 lines
3.0 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * networking/network_policy/editing-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-edit_{context}"]
|
|
= Editing a {name} policy
|
|
|
|
You can edit 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 edit a network policy in any namespace 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
|
|
|
|
. Optional: To list the {name} policy objects in a namespace, enter the following command:
|
|
+
|
|
[source,terminal,subs="attributes+"]
|
|
----
|
|
$ oc get {name}policy
|
|
----
|
|
+
|
|
--
|
|
where:
|
|
|
|
`<namespace>`:: Optional: Specifies the namespace if the object is defined in a different namespace than the current namespace.
|
|
--
|
|
|
|
. Edit the {name} policy object.
|
|
|
|
** If you saved the {name} policy definition in a file, edit the file and make any necessary changes, and then enter the following command.
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc apply -n <namespace> -f <policy_file>.yaml
|
|
----
|
|
+
|
|
--
|
|
where:
|
|
|
|
`<namespace>`:: Optional: Specifies the namespace if the object is defined in a different namespace than the current namespace.
|
|
`<policy_file>`:: Specifies the name of the file containing the network policy.
|
|
--
|
|
|
|
** If you need to update the {name} policy object directly, enter the following command:
|
|
+
|
|
[source,terminal,subs="attributes+"]
|
|
----
|
|
$ oc edit {name}policy <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.
|
|
--
|
|
|
|
. Confirm that the {name} policy object is updated.
|
|
+
|
|
[source,terminal,subs="attributes+"]
|
|
----
|
|
$ oc describe {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.
|
|
--
|
|
|
|
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 editing 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[] |