Skip to content

Commit 6e624f5

Browse files
committed
OSDOCS-9690: adds create network policy to MicroShift
1 parent 3659bfe commit 6e624f5

9 files changed

+77
-14
lines changed

_topic_maps/_topic_map_ms.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,14 @@ Topics:
405405
- Name: Network policies
406406
Dir: microshift-network-policy
407407
Topics:
408-
- Name: Setting network policies
408+
- Name: About network policies
409409
File: microshift-network-policy-index
410+
- Name: Creating network policies
411+
File: microshift-creating-network-policy
410412
- Name: Firewall configuration
411413
File: microshift-firewall
412414
- Name: Networking settings for fully disconnected hosts
413415
File: microshift-disconnected-network-config
414-
415416
---
416417
Name: Storage
417418
Dir: microshift_storage
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
[id="microshift-creating-network-policy"]
3+
= Creating network policies
4+
include::_attributes/attributes-microshift.adoc[]
5+
include::_attributes/common-attributes.adoc[]
6+
:context: microshift-creating-network-policy
7+
8+
toc::[]
9+
10+
You can create a network policy for a namespace.
11+
12+
//OCP modules, edit using conditions and with care (check OCP previews, too)
13+
include::modules/nw-networkpolicy-object.adoc[leveloffset=+1]
14+
15+
include::modules/nw-networkpolicy-create-cli.adoc[leveloffset=+1]
16+
17+
include::modules/nw-networkpolicy-deny-all-allowed.adoc[leveloffset=+1]
18+
19+
include::modules/nw-networkpolicy-allow-external-clients.adoc[leveloffset=+1]
20+
21+
include::modules/nw-networkpolicy-allow-application-all-namespaces.adoc[leveloffset=+1]
22+
23+
include::modules/nw-networkpolicy-allow-application-particular-namespace.adoc[leveloffset=+1]

microshift_networking/microshift-network-policy/microshift-network-policy-index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
:_mod-docs-content-type: ASSEMBLY
22
[id="microshift-network-policies"]
3-
= Setting network policies
3+
= About network policies
44
include::_attributes/attributes-microshift.adoc[]
55
:context: microshift-network-policies
66
toc::[]
77

8-
Learn how to apply network policies to restrict or allow network traffic to pods in your cluster.
8+
Learn how network policies work for {microshift-short} to restrict or allow network traffic to pods in your cluster.
99

1010
include::modules/microshift-nw-network-policy-intro.adoc[leveloffset=+1]
1111

modules/nw-networkpolicy-allow-application-all-namespaces.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// * networking/multiple_networks/configuring-multi-network-policy.adoc
44
// * networking/network_policy/creating-network-policy.adoc
5+
// * microshift_networking/microshift-creating-network-policy.adoc
56

67
:name: network
78
:role: admin
@@ -15,18 +16,23 @@ endif::[]
1516
[id="nw-networkpolicy-allow-traffic-from-all-applications_{context}"]
1617
= Creating a {name} policy allowing traffic to an application from all namespaces
1718

19+
ifndef::microshift[]
1820
[NOTE]
1921
====
2022
If you log in with a user with the `cluster-admin` role, then you can create a network policy in any namespace in the cluster.
2123
====
24+
endif::microshift[]
2225

2326
Follow this procedure to configure a policy that allows traffic from all pods in all namespaces to a particular application.
2427

2528
.Prerequisites
26-
29+
ifndef::microshift[]
2730
* 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.
31+
endif::microshift[]
2832
* You installed the OpenShift CLI (`oc`).
33+
ifndef::microshift[]
2934
* You are logged in to the cluster with a user with `{role}` privileges.
35+
endif::microshift[]
3036
* You are working in the namespace that the {name} policy applies to.
3137

3238
.Procedure

modules/nw-networkpolicy-allow-application-particular-namespace.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// * networking/multiple_networks/configuring-multi-network-policy.adoc
44
// * networking/network_policy/creating-network-policy.adoc
5+
// * microshift_networking/microshift-creating-network-policy.adoc
56

67
:name: network
78
:role: admin
@@ -15,21 +16,26 @@ endif::[]
1516
[id="nw-networkpolicy-allow-traffic-from-a-namespace_{context}"]
1617
= Creating a {name} policy allowing traffic to an application from a namespace
1718

19+
ifndef::microshift[]
1820
[NOTE]
1921
====
2022
If you log in with a user with the `cluster-admin` role, then you can create a network policy in any namespace in the cluster.
2123
====
24+
endif::microshift[]
2225

2326
Follow this procedure to configure a policy that allows traffic to a pod with the label `app=web` from a particular namespace. You might want to do this to:
2427

2528
* Restrict traffic to a production database only to namespaces where production workloads are deployed.
2629
* Enable monitoring tools deployed to a particular namespace to scrape metrics from the current namespace.
2730
2831
.Prerequisites
29-
32+
ifndef::microshift[]
3033
* 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.
34+
endif::microshift[]
3135
* You installed the OpenShift CLI (`oc`).
36+
ifndef::microshift[]
3237
* You are logged in to the cluster with a user with `{role}` privileges.
38+
endif::microshift[]
3339
* You are working in the namespace that the {name} policy applies to.
3440

3541
.Procedure

modules/nw-networkpolicy-allow-external-clients.adoc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,29 @@ endif::[]
1717

1818
With the `deny-by-default` policy in place you can proceed to configure a policy that allows traffic from external clients to a pod with the label `app=web`.
1919

20+
ifndef::microshift[]
2021
[NOTE]
2122
====
2223
If you log in with a user with the `cluster-admin` role, then you can create a network policy in any namespace in the cluster.
2324
====
25+
endif::microshift[]
26+
ifdef::microshift[]
27+
[NOTE]
28+
====
29+
Firewalld rules run before any `NetworkPolicy` is enforced.
30+
====
31+
endif::microshift[]
2432

2533
Follow this procedure to configure a policy that allows external service from the public Internet directly or by using a Load Balancer to access the pod. Traffic is only allowed to a pod with the label `app=web`.
2634

2735
.Prerequisites
28-
36+
ifndef::microshift[]
2937
* 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.
38+
endif::microshift[]
3039
* You installed the OpenShift CLI (`oc`).
40+
ifndef::microshift[]
3141
* You are logged in to the cluster with a user with `{role}` privileges.
42+
endif::microshift[]
3243
* You are working in the namespace that the {name} policy applies to.
3344

3445
.Procedure
@@ -80,10 +91,11 @@ ifdef::multi[]
8091
multinetworkpolicy.k8s.cni.cncf.io/web-allow-external created
8192
endif::multi[]
8293
----
83-
94+
ifndef::microshift[]
8495
This policy allows traffic from all resources, including external traffic as illustrated in the following diagram:
8596

8697
image::292_OpenShift_Configuring_multi-network_policy_1122.png[Allow traffic from external clients]
98+
endif::microshift[]
8799

88100
ifdef::multi[]
89101
:!multi:

modules/nw-networkpolicy-create-cli.adoc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// * networking/multiple_networks/configuring-multi-network-policy.adoc
44
// * networking/network_policy/creating-network-policy.adoc
55
// * post_installation_configuration/network-configuration.adoc
6+
// * microshift_networking/microshift-creating-network-policy.adoc
67

78
:name: network
89
:role: admin
@@ -18,18 +19,21 @@ endif::[]
1819

1920
To define granular rules describing ingress or egress network traffic allowed for namespaces in your cluster, you can create a {name} policy.
2021

21-
ifndef::multi[]
22+
ifndef::multi,microshift[]
2223
[NOTE]
2324
====
2425
If you log in with a user with the `cluster-admin` role, then you can create a network policy in any namespace in the cluster.
2526
====
26-
endif::multi[]
27+
endif::multi,microshift[]
2728

2829
.Prerequisites
29-
30+
ifndef::microshift[]
3031
* 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.
32+
endif::microshift[]
3133
* You installed the OpenShift CLI (`oc`).
34+
ifndef::microshift[]
3235
* You are logged in to the cluster with a user with `{role}` privileges.
36+
endif::microshift[]
3337
* You are working in the namespace that the {name} policy applies to.
3438

3539
.Procedure
@@ -235,7 +239,9 @@ endif::multi[]
235239
:!name:
236240
:!role:
237241

242+
ifndef::microshift[]
238243
[NOTE]
239244
====
240245
If you log in to the web console with `cluster-admin` privileges, you have a choice of creating a network policy in any namespace in the cluster directly in YAML or from a form in the web console.
241246
====
247+
endif::microshift[]

modules/nw-networkpolicy-deny-all-allowed.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// * networking/multiple_networks/configuring-multi-network-policy.adoc
44
// * networking/network_policy/creating-network-policy.adoc
5+
// * microshift_networking/microshift-creating-network-policy.adoc
56

67
:name: network
78
:role: admin
@@ -17,16 +18,21 @@ endif::[]
1718

1819
This is a fundamental policy, blocking all cross-pod networking other than network traffic allowed by the configuration of other deployed network policies. This procedure enforces a default `deny-by-default` policy.
1920

21+
ifndef::microshift[]
2022
[NOTE]
2123
====
2224
If you log in with a user with the `cluster-admin` role, then you can create a network policy in any namespace in the cluster.
2325
====
26+
endif::microshift[]
2427

2528
.Prerequisites
26-
29+
ifndef::microshift[]
2730
* 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.
31+
endif::microshift[]
2832
* You installed the OpenShift CLI (`oc`).
33+
ifndef::microshift[]
2934
* You are logged in to the cluster with a user with `{role}` privileges.
35+
endif::microshift[]
3036
* You are working in the namespace that the {name} policy applies to.
3137

3238
.Procedure

modules/nw-networkpolicy-object.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// * networking/network_policy/viewing-network-policy.adoc
55
// * networking/network_policy/editing-network-policy.adoc
66
// * post_installation_configuration/network-configuration.adoc
7+
// * microshift_networking/microshift-creating-network-policy.adoc
78

89
:_mod-docs-content-type: REFERENCE
910
[id="nw-networkpolicy-object_{context}"]
@@ -31,7 +32,9 @@ spec:
3132
port: 27017
3233
----
3334
<1> The name of the NetworkPolicy object.
34-
<2> A selector that describes the pods to which the policy applies. The policy object can
35-
only select pods in the project that defines the NetworkPolicy object.
35+
<2> A selector that describes the pods to which the policy applies.
36+
ifndef::microshift[]
37+
The policy object can only select pods in the project that defines the NetworkPolicy object.
38+
endif::microshift[]
3639
<3> A selector that matches the pods from which the policy object allows ingress traffic. The selector matches pods in the same namespace as the NetworkPolicy.
3740
<4> A list of one or more destination ports on which to accept traffic.

0 commit comments

Comments
 (0)