Skip to content

Commit 10d8d79

Browse files
authored
Add prometheus network policy to network policy e2e (operator-framework#2043)
Signed-off-by: Todd Short <[email protected]>
1 parent 9380928 commit 10d8d79

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/e2e/network_policy_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@ var denyAllPolicySpec = allowedPolicyDefinition{
6565
denyAllEgressJustification: "Denies all egress traffic from pods selected by this policy by default, unless explicitly allowed by other policy rules, minimizing potential exfiltration paths.",
6666
}
6767

68+
var prometheuSpec = allowedPolicyDefinition{
69+
selector: metav1.LabelSelector{MatchLabels: map[string]string{"app.kubernetes.io/name": "prometheus"}},
70+
policyTypes: []networkingv1.PolicyType{networkingv1.PolicyTypeIngress, networkingv1.PolicyTypeEgress},
71+
ingressRule: ingressRule{
72+
ports: []portWithJustification{
73+
{
74+
port: nil,
75+
justification: "Allows access to the prometheus pod",
76+
},
77+
},
78+
},
79+
egressRule: egressRule{
80+
ports: []portWithJustification{
81+
{
82+
port: nil,
83+
justification: "Allows prometheus to access other pods",
84+
},
85+
},
86+
},
87+
}
88+
6889
// Ref: https://docs.google.com/document/d/1bHEEWzA65u-kjJFQRUY1iBuMIIM1HbPy4MeDLX4NI3o/edit?usp=sharing
6990
var allowedNetworkPolicies = map[string]allowedPolicyDefinition{
7091
"catalogd-controller-manager": {
@@ -163,6 +184,8 @@ func TestNetworkPolicyJustifications(t *testing.T) {
163184
} else {
164185
t.Log("Detected single-namespace configuration, expecting one 'default-deny-all-traffic' policy.")
165186
allowedNetworkPolicies["default-deny-all-traffic"] = denyAllPolicySpec
187+
t.Log("Detected single-namespace configuration, expecting 'prometheus' policy.")
188+
allowedNetworkPolicies["prometheus"] = prometheuSpec
166189
}
167190

168191
validatedRegistryPolicies := make(map[string]bool)

0 commit comments

Comments
 (0)