Edit a network policy
To modify existing policy configurations, you can edit a network policy in a namespace. Edit policies by modifying the policy file and applying it with oc apply, or by using the oc edit command directly.
|
|
If you log in with |
|
|
If you log in with |
-
Your cluster uses a network plugin that supports
NetworkPolicyobjects, such as the OVN-Kubernetes network plugin, withmode: NetworkPolicyset. -
You installed the OpenShift CLI (
oc). -
You are logged in to the cluster with a user with
adminprivileges. -
You are working in the namespace where the network policy exists.
-
Optional: To list the network policy objects in a namespace, enter the following command:
$ oc get network policy -n <namespace>where:
<namespace>-
Optional: Specifies the namespace if the object is defined in a different namespace than the current namespace.
-
Edit the network policy object.
-
If you saved the network policy definition in a file, edit the file and make any necessary changes, and then enter the following command.
$ oc apply -n <namespace> -f <policy_file>.yamlwhere:
<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 network policy object directly, enter the following command:
$ oc edit network 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 network policy object is updated.
$ oc describe 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.