|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/network_policy/creating-network-policy.adoc |
| 4 | +// * post_installation_configuration/network-configuration.adoc |
| 5 | + |
| 6 | +:_content-type: PROCEDURE |
| 7 | +[id="nw-networkpolicy-create-ocm_{context}"] |
| 8 | += Creating a network policy using {cluster-manager} |
| 9 | + |
| 10 | +To define granular rules describing the ingress or egress network traffic allowed for namespaces in your cluster, you can create a network policy. |
| 11 | + |
| 12 | +.Prerequisites |
| 13 | + |
| 14 | +* You logged in to {cluster-manager-url}. |
| 15 | +* You created an {product-title} cluster. |
| 16 | +* You configured an identity provider for your cluster. |
| 17 | +* You added your user account to the configured identity provider. |
| 18 | +* You created a project within your {product-title} cluster. |
| 19 | +
|
| 20 | +.Procedure |
| 21 | + |
| 22 | +. From {cluster-manager-url}, click on the cluster you want to access. |
| 23 | + |
| 24 | +. Click *Open console* to navigate to the OpenShift web console. |
| 25 | + |
| 26 | +. Click on your identity provider and provide your credentials to log in to the cluster. |
| 27 | + |
| 28 | +. From the administrator perspective, under *Networking*, click *NetworkPolicies*. |
| 29 | + |
| 30 | +. Click *Create NetworkPolicy*. |
| 31 | + |
| 32 | +. Provide a name for the policy in the *Policy name* field. |
| 33 | + |
| 34 | +. Optional: You can provide the label and selector for a specific pod if this policy applies only to one or more specific pods. If you do not select a specific pod, then this policy will be applicable to all pods on the cluster. |
| 35 | + |
| 36 | +. Optional: You can block all ingress and egress traffic by using the *Deny all ingress traffic* or *Deny all egress traffic* checkboxes. |
| 37 | + |
| 38 | +. You can also add any combination of ingress and egress rules, allowing you to specify the port, namespace, or IP blocks you want to approve. |
| 39 | + |
| 40 | +. Add ingress rules to your policy: |
| 41 | + |
| 42 | +.. Select *Add ingress rule* to configure a new rule. This action creates a new *Ingress rule* row with an *Add allowed source* drop-down menu that enables you to specify how you want to limit inbound traffic. The drop-down menu offers three options to limit your ingress traffic: |
| 43 | ++ |
| 44 | +*** *Allow pods from the same namespace* limits traffic to pods within the same namespace. You can specify the pods in a namespace, but leaving this option blank allows all of the traffic from pods in the namespace. |
| 45 | +
|
| 46 | +*** *Allow pods from inside the cluster* limits traffic to pods within the same cluster as the policy. You can specify namespaces and pods from which you want to allow inbound traffic. Leaving this option blank allows inbound traffic from all namespaces and pods within this cluster. |
| 47 | + |
| 48 | +*** *Allow peers by IP block* limits traffic from a specified Classless Inter-Domain Routing (CIDR) IP block. You can block certain IPs with the exceptions option. Leaving the CIDR field blank allows all inbound traffic from all external sources. |
| 49 | +
|
| 50 | +.. You can restrict all of your inbound traffic to a port. If you do not add any ports then all ports are accessible to traffic. |
| 51 | +
|
| 52 | +. Add egress rules to your network policy: |
| 53 | +
|
| 54 | +.. Select *Add egress rule* to configure a new rule. This action creates a new *Egress rule* row with an *Add allowed destination*"* drop-down menu that enables you to specify how you want to limit outbound traffic. The drop-down menu offers three options to limit your egress traffic: |
| 55 | ++ |
| 56 | +*** *Allow pods from the same namespace* limits outbound traffic to pods within the same namespace. You can specify the pods in a namespace, but leaving this option blank allows all of the traffic from pods in the namespace. |
| 57 | + |
| 58 | +*** *Allow pods from inside the cluster* limits traffic to pods within the same cluster as the policy. You can specify namespaces and pods from which you want to allow outbound traffic. Leaving this option blank allows outbound traffic from all namespaces and pods within this cluster. |
| 59 | +
|
| 60 | +*** *Allow peers by IP block* limits traffic from a specified CIDR IP block. You can block certain IPs with the exceptions option. Leaving the CIDR field blank allows all outbound traffic from all external sources. |
| 61 | + |
| 62 | +.. You can restrict all of your outbound traffic to a port. If you do not add any ports then all ports are accessible to traffic. |
0 commit comments