Editing a network policy

    You can edit a network policy in a namespace.

    Prerequisites

    • You installed the OpenShift CLI ().

    • You are logged in to the cluster with a user with admin privileges.

    • You are working in the namespace where the network policy exists.

    Procedure

    1. 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.

        where:

        <namespace>

        Optional: Specifies the namespace if the object is defined in a different namespace than the current namespace.

        Specifies the name of the file containing the network policy.

      • If you need to update the network policy object directly, enter the following command:

        where:

        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.

    The following annotates an example NetworkPolicy object:

    1The name of the NetworkPolicy object.
    2A selector describing the pods the policy applies to. The policy object can only select pods in the project that the NetworkPolicy object is defined.
    3A selector matching the pods that the policy object allows ingress traffic from. The selector will match pods in any project.
    4A list of one or more destination ports to accept traffic on.