Skip to content

Commit 3b206a7

Browse files
kabicinkabicin
authored andcommitted
Update utils.go
1 parent 61da11b commit 3b206a7

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
@@ -481,11 +481,12 @@ func CustomizeNetworkPolicy(networkPolicy *networkingv1.NetworkPolicy, isOpenShi
481481
networkPolicy.Spec.Egress = []networkingv1.NetworkPolicyEgressRule{}
482482
} else {
483483
egressConfigured := ba.GetNetworkPolicy() != nil && (ba.GetNetworkPolicy().GetToLabels() != nil || ba.GetNetworkPolicy().GetToNamespaceLabels() != nil)
484-
if egressConfigured {
484+
egressBypass := ba.GetNetworkPolicy() != nil && ba.GetNetworkPolicy().IsBypassingDenyAllEgress() // check if egress should bypass deny all policy to access the API server and DNS
485+
if egressConfigured || egressBypass {
485486
if !hasEgressPolicy {
486487
networkPolicy.Spec.PolicyTypes = append(networkPolicy.Spec.PolicyTypes, networkingv1.PolicyTypeEgress)
487488
}
488-
egressBypass := ba.GetNetworkPolicy() != nil && ba.GetNetworkPolicy().IsBypassingDenyAllEgress() // check if egress should bypass deny all policy to access the API server and DNS
489+
489490
networkPolicy.Spec.Egress = createNetworkPolicyEgressRules(networkPolicy, isOpenShift, egressBypass, getDNSEgressRule, getEndpoints, ba)
490491
} else {
491492
// if egress is not configured, consider the network policy disabled

0 commit comments

Comments
 (0)