Skip to content

MultiNetworkPolicy does not allow for empty podSelector #26

@trozet

Description

@trozet

NetworkPolicy allows an empty podSelector:

// NetworkPolicySpec provides the specification of a NetworkPolicy
type NetworkPolicySpec struct {
	// podSelector selects the pods to which this NetworkPolicy object applies.
	// The array of ingress rules is applied to any pods selected by this field.
	// Multiple network policies can select the same set of pods. In this case,
	// the ingress rules for each are combined additively.
	// This field is NOT optional and follows standard label selector semantics.
	// An empty podSelector matches all pods in this namespace.
	PodSelector metav1.LabelSelector `json:"podSelector" protobuf:"bytes,1,opt,name=podSelector"`

However, MultiNetworkPolicy does not:

trozet@fedora:~/go/src/github.com/ovn-org/ovn-kubernetes/contrib$ cat /home/trozet/network_policy_port_range_udn.yml
---
apiVersion: k8s.cni.cncf.io/v1beta1
kind: MultiNetworkPolicy
metadata:
  name: deny-by-default
  annotations:
    k8s.v1.cni.cncf.io/policy-for: ns1/l3-network
spec:
  podSelector:
#    matchLabels:
#      key: value
  policyTypes:
  - Egress
  egress: 
   - to:
     - ipBlock:
         cidr: 10.244.0.0/16
     ports:
       - protocol: TCP
         port: 15384
         endPort: 65535
       - port: 1337
         endPort: 1338    
trozet@fedora:~/go/src/github.com/ovn-org/ovn-kubernetes/contrib$ oc create -f /home/trozet/network_policy_port_range_udn.yml
The MultiNetworkPolicy "deny-by-default" is invalid: spec.podSelector: Required value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions