4.5. Viewing a network policy
Use the following procedure to view a network policy for a namespace.
4.5.1. Viewing network policies using the CLI 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
You can examine the network policies in a namespace.
Prerequisites
-
You installed the OpenShift CLI (
oc). - You are working in the namespace where the network policy exists.
Procedure
List network policies in a namespace.
To view network policy objects defined in a namespace enter the following command:
$ oc get networkpolicyOptional: To examine a specific network policy enter the following command:
$ oc describe networkpolicy <policy_name> -n <namespace>where:
<policy_name>- Specifies the name of the network policy to inspect.
<namespace>Optional: Specifies the namespace if the object is defined in a different namespace than the current namespace.
$ oc describe networkpolicy allow-same-namespaceName: allow-same-namespace Namespace: ns1 Created on: 2021-05-24 22:28:56 -0400 EDT Labels: <none> Annotations: <none> Spec: PodSelector: <none> (Allowing the specific traffic to all pods in this namespace) Allowing ingress traffic: To Port: <any> (traffic allowed to all ports) From: PodSelector: <none> Not affecting egress traffic Policy Types: Ingress