Skip to content

Commit ed6b2cd

Browse files
committed
Update utils.go
1 parent 0527543 commit ed6b2cd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

utils/utils.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,12 @@ func CustomizeNetworkPolicy(networkPolicy *networkingv1.NetworkPolicy, isOpenShi
471471
networkPolicy.Spec.Egress = []networkingv1.NetworkPolicyEgressRule{}
472472
} else {
473473
egressConfigured := ba.GetNetworkPolicy() != nil && (ba.GetNetworkPolicy().GetToLabels() != nil || ba.GetNetworkPolicy().GetToNamespaceLabels() != nil)
474-
if egressConfigured {
474+
egressBypass := ba.GetNetworkPolicy() != nil && ba.GetNetworkPolicy().IsBypassingDenyAllEgress() // check if egress should bypass deny all policy to access the API server and DNS
475+
if egressConfigured || egressBypass {
475476
if !hasEgressPolicy {
476477
networkPolicy.Spec.PolicyTypes = append(networkPolicy.Spec.PolicyTypes, networkingv1.PolicyTypeEgress)
477478
}
478-
egressBypass := ba.GetNetworkPolicy() != nil && ba.GetNetworkPolicy().IsBypassingDenyAllEgress() // check if egress should bypass deny all policy to access the API server and DNS
479+
479480
networkPolicy.Spec.Egress = createNetworkPolicyEgressRules(networkPolicy, isOpenShift, egressBypass, getDNSEgressRule, getEndpoints, ba)
480481
} else {
481482
// if egress is not configured, consider the network policy disabled

0 commit comments

Comments
 (0)