File tree Expand file tree Collapse file tree 2 files changed +425
-2
lines changed Expand file tree Collapse file tree 2 files changed +425
-2
lines changed Original file line number Diff line number Diff line change @@ -223,15 +223,23 @@ func (c Converter) NetworkPolicyToPolicy(np *extensions.NetworkPolicy) (*model.K
223
223
types := []string {}
224
224
if ingress {
225
225
types = append (types , "ingress" )
226
- } else if len (inboundRules ) > 0 {
227
- log .Warn ("K8s PolicyTypes don't include 'ingress', but NetworkPolicy has ingress rules." )
228
226
}
229
227
if egress {
230
228
types = append (types , "egress" )
231
229
} else if len (outboundRules ) > 0 {
230
+ // Egress was introduced at the same time as policyTypes. It shouldn't be possible to
231
+ // receive a NetworkPolicy with an egress rule but without "egress" specified in its types,
232
+ // but we'll warn about it anyway.
232
233
log .Warn ("K8s PolicyTypes don't include 'egress', but NetworkPolicy has egress rules." )
233
234
}
234
235
236
+ // If no types were specified in the policy, then we're running on a cluster that doesn't
237
+ // include support for that field in the API. In that case, the correct behavior is for the policy
238
+ // to apply to only ingress traffic.
239
+ if len (types ) == 0 {
240
+ types = append (types , "ingress" )
241
+ }
242
+
235
243
// Build and return the KVPair.
236
244
return & model.KVPair {
237
245
Key : model.PolicyKey {
You can’t perform that action at this time.
0 commit comments