Skip to content

Commit f6c1cf2

Browse files
authored
Merge pull request #143 from tssurya/implement-egress-traffic-semantics
Implement Cluster Egress Traffic semantics (ANP&BANP NorthBound Support) - PART1 - Nodes
2 parents 6774f36 + 23d3882 commit f6c1cf2

8 files changed

+274
-121
lines changed

apis/v1alpha1/adminnetworkpolicy_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ type AdminNetworkPolicyIngressRule struct {
128128
Action AdminNetworkPolicyRuleAction `json:"action"`
129129

130130
// From is the list of sources whose traffic this rule applies to.
131-
// If any AdminNetworkPolicyPeer matches the source of incoming
131+
// If any AdminNetworkPolicyIngressPeer matches the source of incoming
132132
// traffic then the specified action is applied.
133133
// This field must be defined and contain at least one item.
134134
//
135135
// Support: Core
136136
//
137137
// +kubebuilder:validation:MinItems=1
138138
// +kubebuilder:validation:MaxItems=100
139-
From []AdminNetworkPolicyPeer `json:"from"`
139+
From []AdminNetworkPolicyIngressPeer `json:"from"`
140140

141141
// Ports allows for matching traffic based on port and protocols.
142142
// This field is a list of ports which should be matched on
@@ -180,18 +180,18 @@ type AdminNetworkPolicyEgressRule struct {
180180
Action AdminNetworkPolicyRuleAction `json:"action"`
181181

182182
// To is the List of destinations whose traffic this rule applies to.
183-
// If any AdminNetworkPolicyPeer matches the destination of outgoing
183+
// If any AdminNetworkPolicyEgressPeer matches the destination of outgoing
184184
// traffic then the specified action is applied.
185185
// This field must be defined and contain at least one item.
186186
//
187187
// Support: Core
188188
//
189189
// +kubebuilder:validation:MinItems=1
190190
// +kubebuilder:validation:MaxItems=100
191-
To []AdminNetworkPolicyPeer `json:"to"`
191+
To []AdminNetworkPolicyEgressPeer `json:"to"`
192192

193193
// Ports allows for matching traffic based on port and protocols.
194-
// This field is a list of destination ports for the outging egress traffic.
194+
// This field is a list of destination ports for the outgoing egress traffic.
195195
// If Ports is not set then the rule does not filter traffic via port.
196196
//
197197
// Support: Core

apis/v1alpha1/baselineadminnetworkpolicy_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ type BaselineAdminNetworkPolicyIngressRule struct {
112112
Action BaselineAdminNetworkPolicyRuleAction `json:"action"`
113113

114114
// From is the list of sources whose traffic this rule applies to.
115-
// If any AdminNetworkPolicyPeer matches the source of incoming
115+
// If any AdminNetworkPolicyIngressPeer matches the source of incoming
116116
// traffic then the specified action is applied.
117117
// This field must be defined and contain at least one item.
118118
//
119119
// Support: Core
120120
//
121121
// +kubebuilder:validation:MinItems=1
122122
// +kubebuilder:validation:MaxItems=100
123-
From []AdminNetworkPolicyPeer `json:"from"`
123+
From []AdminNetworkPolicyIngressPeer `json:"from"`
124124

125125
// Ports allows for matching traffic based on port and protocols.
126126
// This field is a list of ports which should be matched on
@@ -160,15 +160,15 @@ type BaselineAdminNetworkPolicyEgressRule struct {
160160
Action BaselineAdminNetworkPolicyRuleAction `json:"action"`
161161

162162
// To is the list of destinations whose traffic this rule applies to.
163-
// If any AdminNetworkPolicyPeer matches the destination of outgoing
163+
// If any AdminNetworkPolicyEgressPeer matches the destination of outgoing
164164
// traffic then the specified action is applied.
165165
// This field must be defined and contain at least one item.
166166
// +kubebuilder:validation:MinItems=1
167167
// +kubebuilder:validation:MaxItems=100
168168
//
169169
// Support: Core
170170
//
171-
To []AdminNetworkPolicyPeer `json:"to"`
171+
To []AdminNetworkPolicyEgressPeer `json:"to"`
172172

173173
// Ports allows for matching traffic based on port and protocols.
174174
// This field is a list of destination ports for the outging egress traffic.

apis/v1alpha1/shared_types.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ type PortRange struct {
120120
End int32 `json:"end"`
121121
}
122122

123-
// AdminNetworkPolicyPeer defines an in-cluster peer to allow traffic to/from.
123+
// AdminNetworkPolicyIngressPeer defines an in-cluster peer to allow traffic from.
124124
// Exactly one of the selector pointers must be set for a given peer. If a
125125
// consumer observes none of its fields are set, they must assume an unknown
126126
// option has been specified and fail closed.
127127
// +kubebuilder:validation:MaxProperties=1
128128
// +kubebuilder:validation:MinProperties=1
129-
type AdminNetworkPolicyPeer struct {
129+
type AdminNetworkPolicyIngressPeer struct {
130130
// Namespaces defines a way to select all pods within a set of Namespaces.
131131
// Note that host-networked pods are not included in this type of peer.
132132
//
@@ -135,7 +135,7 @@ type AdminNetworkPolicyPeer struct {
135135
// +optional
136136
Namespaces *NamespacedPeer `json:"namespaces,omitempty"`
137137
// Pods defines a way to select a set of pods in
138-
// in a set of namespaces. Note that host-networked pods
138+
// a set of namespaces. Note that host-networked pods
139139
// are not included in this type of peer.
140140
//
141141
// Support: Core
@@ -144,6 +144,39 @@ type AdminNetworkPolicyPeer struct {
144144
Pods *NamespacedPodPeer `json:"pods,omitempty"`
145145
}
146146

147+
// AdminNetworkPolicyEgressPeer defines a peer to allow traffic to.
148+
// Exactly one of the selector pointers must be set for a given peer. If a
149+
// consumer observes none of its fields are set, they must assume an unknown
150+
// option has been specified and fail closed.
151+
// +kubebuilder:validation:MaxProperties=1
152+
// +kubebuilder:validation:MinProperties=1
153+
type AdminNetworkPolicyEgressPeer struct {
154+
// Namespaces defines a way to select all pods within a set of Namespaces.
155+
// Note that host-networked pods are not included in this type of peer.
156+
//
157+
// Support: Core
158+
//
159+
// +optional
160+
Namespaces *NamespacedPeer `json:"namespaces,omitempty"`
161+
// Pods defines a way to select a set of pods in
162+
// a set of namespaces. Note that host-networked pods
163+
// are not included in this type of peer.
164+
//
165+
// Support: Core
166+
//
167+
// +optional
168+
Pods *NamespacedPodPeer `json:"pods,omitempty"`
169+
// Nodes defines a way to select a set of nodes in
170+
// the cluster. This field follows standard label selector
171+
// semantics; if present but empty, it selects all Nodes.
172+
//
173+
// Support: Extended
174+
//
175+
// <network-policy-api:experimental>
176+
// +optional
177+
Nodes *metav1.LabelSelector `json:"nodes,omitempty"`
178+
}
179+
147180
// NamespacedPeer defines a flexible way to select Namespaces in a cluster.
148181
// Exactly one of the selectors must be set. If a consumer observes none of
149182
// its fields are set, they must assume an unknown option has been specified

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 59 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)