Skip to content

Commit d629829

Browse files
committed
OSDOCS-6084: Adding network policy for network observability
1 parent 832ac8e commit d629829

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,8 @@ Topics:
14771477
File: understanding-network-observability-operator
14781478
- Name: Configuring the Network Observability Operator
14791479
File: configuring-operator
1480+
- Name: Network Policy
1481+
File: network-observability-network-policy
14801482
- Name: Observing the network traffic
14811483
File: observing-network-traffic
14821484
- Name: Monitoring the Network Observability Operator
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Module included in the following assemblies:
2+
3+
// * networking/network_observability/network-observability-network-policy.adoc
4+
5+
6+
:_content-type: PROCEDURE
7+
[id="network-observability-network-policy_{context}"]
8+
= Creating a network policy for Network Observability
9+
You might need to create a network policy to secure ingress traffic to the `netobserv` namespace. In the web console, you can create a network policy using the form view.
10+
11+
.Procedure
12+
. Navigate to *Networking* -> *NetworkPolicies*.
13+
. Select the `netobserv` project from the *Project* dropdown menu.
14+
. Name the policy. For this example, the policy name is `allow-ingress`.
15+
. Click *Add ingress rule* three times to create three ingress rules.
16+
. Specify the following in the form:
17+
.. Make the following specifications for the first *Ingress rule*:
18+
... From the *Add allowed source* dropdown menu, select *Allow pods from the same namespace*.
19+
.. Make the following specifications for the second *Ingress rule*:
20+
... From the *Add allowed source* dropdown menu, select *Allow pods from inside the cluster*.
21+
... Click *+ Add namespace selector*.
22+
... Add the label, `kubernetes.io/metadata.name`, and the selector, `openshift-console`.
23+
.. Make the following specifications for the third *Ingress rule*:
24+
... From the *Add allowed source* dropdown menu, select *Allow pods from inside the cluster*.
25+
... Click *+ Add namespace selector*.
26+
... Add the label, `kubernetes.io/metadata.name`, and the selector, `openshift-monitoring`.
27+
28+
.Verification
29+
. Navigate to *Observe* -> *Network Traffic*.
30+
. View the *Traffic Flows* tab, or any tab, to verify that the data is displayed.
31+
. Navigate to *Observe* -> *Dashboards*. In the NetObserv/Health selection, verify that the flows are being ingested and sent to Loki, which is represented in the first graph.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Module included in the following assemblies:
2+
3+
// * networking/network_observability/network-observability-network-policy.adoc
4+
5+
:_content-type: REFERENCE
6+
[id="network-observability-sample-network-policy_{context}"]
7+
= Example network policy
8+
The following annotates an example `NetworkPolicy` object for the `netobserv` namespace:
9+
10+
[id="network-observability-network-policy-sample_{context}"]
11+
.Sample network policy
12+
[source, yaml]
13+
----
14+
kind: NetworkPolicy
15+
apiVersion: networking.k8s.io/v1
16+
metadata:
17+
name: allow-ingress
18+
namespace: netobserv
19+
spec:
20+
podSelector: {} <1>
21+
ingress:
22+
- from:
23+
- podSelector: {} <2>
24+
namespaceSelector: <3>
25+
matchLabels:
26+
kubernetes.io/metadata.name: openshift-console
27+
- podSelector: {}
28+
namespaceSelector:
29+
matchLabels:
30+
kubernetes.io/metadata.name: openshift-monitoring
31+
policyTypes:
32+
- Ingress
33+
status: {}
34+
----
35+
<1> A selector that describes the pods to which the policy applies. The policy object can only select pods in the project that defines the `NetworkPolicy` object. In this documentation, it would be the project in which the Network Observability Operator is installed, which is the `netobserv` project.
36+
<2> A selector that matches the pods from which the policy object allows ingress traffic. The default is that the selector matches pods in the same namespace as the `NetworkPolicy`.
37+
<3> When the `namespaceSelector` is specified, the selector matches pods in the specified namespace.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
:_content-type: ASSEMBLY
2+
[id="network-observability-network-policy"]
3+
= Network Policy
4+
include::_attributes/common-attributes.adoc[]
5+
:context: network_observability
6+
7+
toc::[]
8+
9+
As a user with the `admin` role, you can create a network policy for the `netobserv` namespace.
10+
11+
include::modules/network-observability-create-network-policy.adoc[leveloffset=+1]
12+
include::modules/network-observability-sample-network-policy-YAML.adoc[leveloffset=+1]
13+
14+
[role="_additional-resources"]
15+
.Additional resources
16+
xref:../../networking/network_policy/creating-network-policy.adoc#nw-networkpolicy-object_creating-network-policy[Creating a network policy using the CLI]

0 commit comments

Comments
 (0)