@@ -219,6 +219,100 @@ type AdminNetworkPolicyEgressRule struct {
219
219
// +kubebuilder:validation:Enum={"Allow", "Deny", "Pass"}
220
220
type AdminNetworkPolicyRuleAction string
221
221
222
+ // AdminNetworkPolicyEgressPeer defines a peer to allow traffic to.
223
+ // Exactly one of the selector pointers must be set for a given peer. If a
224
+ // consumer observes none of its fields are set, they must assume an unknown
225
+ // option has been specified and fail closed.
226
+ // +kubebuilder:validation:MaxProperties=1
227
+ // +kubebuilder:validation:MinProperties=1
228
+ type AdminNetworkPolicyEgressPeer struct {
229
+ // Namespaces defines a way to select all pods within a set of Namespaces.
230
+ // Note that host-networked pods are not included in this type of peer.
231
+ //
232
+ // Support: Core
233
+ //
234
+ // +optional
235
+ Namespaces * metav1.LabelSelector `json:"namespaces,omitempty"`
236
+ // Pods defines a way to select a set of pods in
237
+ // a set of namespaces. Note that host-networked pods
238
+ // are not included in this type of peer.
239
+ //
240
+ // Support: Core
241
+ //
242
+ // +optional
243
+ Pods * NamespacedPod `json:"pods,omitempty"`
244
+ // Nodes defines a way to select a set of nodes in
245
+ // the cluster. This field follows standard label selector
246
+ // semantics; if present but empty, it selects all Nodes.
247
+ //
248
+ // Support: Extended
249
+ //
250
+ // <network-policy-api:experimental>
251
+ // +optional
252
+ Nodes * metav1.LabelSelector `json:"nodes,omitempty"`
253
+ // Networks defines a way to select peers via CIDR blocks.
254
+ // This is intended for representing entities that live outside the cluster,
255
+ // which can't be selected by pods, namespaces and nodes peers, but note
256
+ // that cluster-internal traffic will be checked against the rule as
257
+ // well. So if you Allow or Deny traffic to `"0.0.0.0/0"`, that will allow
258
+ // or deny all IPv4 pod-to-pod traffic as well. If you don't want that,
259
+ // add a rule that Passes all pod traffic before the Networks rule.
260
+ //
261
+ // Each item in Networks should be provided in the CIDR format and should be
262
+ // IPv4 or IPv6, for example "10.0.0.0/8" or "fd00::/8".
263
+ //
264
+ // Networks can have upto 25 CIDRs specified.
265
+ //
266
+ // Support: Extended
267
+ //
268
+ // <network-policy-api:experimental>
269
+ // +optional
270
+ // +listType=set
271
+ // +kubebuilder:validation:MinItems=1
272
+ // +kubebuilder:validation:MaxItems=25
273
+ Networks []CIDR `json:"networks,omitempty"`
274
+
275
+ // DomainNames provides a way to specify domain names as peers.
276
+ //
277
+ // DomainNames is only supported for ALLOW rules. In order to control
278
+ // access, DomainNames ALLOW rules should be used with a lower priority
279
+ // egress deny -- this allows the admin to maintain an explicit "allowlist"
280
+ // of reachable domains.
281
+ //
282
+ // DomainNames can have up to 25 domain names specified in one rule.
283
+ //
284
+ // Support: Extended
285
+ //
286
+ // <network-policy-api:experimental>
287
+ // +optional
288
+ // +listType=set
289
+ // +kubebuilder:validation:MinItems=1
290
+ // +kubebuilder:validation:MaxItems=25
291
+ DomainNames []DomainName `json:"domainNames,omitempty"`
292
+ }
293
+
294
+ // DomainName describes one or more domain names to be used as a peer.
295
+ //
296
+ // DomainName can be an exact match, or use the wildcard specifier '*' to match
297
+ // one or more labels.
298
+ //
299
+ // '*', the wildcard specifier, matches one or more entire labels. It does not
300
+ // support partial matches. '*' may only be specified as a prefix.
301
+ //
302
+ // Examples:
303
+ // - `kubernetes.io` matches only `kubernetes.io`.
304
+ // It does not match "www.kubernetes.io", "blog.kubernetes.io",
305
+ // "my-kubernetes.io", or "wikipedia.org".
306
+ // - `blog.kubernetes.io` matches only "blog.kubernetes.io".
307
+ // It does not match "www.kubernetes.io" or "kubernetes.io".
308
+ // - `*.kubernetes.io` matches subdomains of kubernetes.io.
309
+ // "www.kubernetes.io", "blog.kubernetes.io", and
310
+ // "latest.blog.kubernetes.io" match, however "kubernetes.io", and
311
+ // "wikipedia.org" do not.
312
+ //
313
+ // +kubebuilder:validation:Pattern=`^(\*\.)?([a-zA-z0-9]([-a-zA-Z0-9_]*[a-zA-Z0-9])?\.)+[a-zA-z0-9]([-a-zA-Z0-9_]*[a-zA-Z0-9])?\.?$`
314
+ type DomainName string
315
+
222
316
const (
223
317
// AdminNetworkPolicyRuleActionAllow indicates that matching traffic will be
224
318
// allowed regardless of NetworkPolicy and BaselineAdminNetworkPolicy
0 commit comments