Skip to content

Commit 153a8b8

Browse files
committed
Add DomainName field to AdminNetworkPolicyEgressPeer
1 parent 150d8c3 commit 153a8b8

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

apis/v1alpha1/shared_types.go

+37
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,21 @@ type AdminNetworkPolicyEgressPeer struct {
196196
// +kubebuilder:validation:MinItems=1
197197
// +kubebuilder:validation:MaxItems=25
198198
Networks []CIDR `json:"networks,omitempty"`
199+
200+
// DomainNames provides a way to specify domain names as peers.
201+
//
202+
// DomainNames is only supported for ALLOW rules. In order to control
203+
// access, DomainNames ALLOW rules should be used with a lower priority
204+
// egress deny -- this allows the admin to maintain an explicit "allowlist"
205+
// of reachable domains.
206+
//
207+
// Support: Extended
208+
//
209+
// <network-policy-api:experimental>
210+
// +optional
211+
// +listType=set
212+
// +kubebuilder:validation:MinItems=1
213+
DomainNames []DomainName `json:"domainNames,omitempty"`
199214
}
200215

201216
// CIDR is an IP address range in CIDR notation (for example, "10.0.0.0/8" or "fd00::/8").
@@ -204,3 +219,25 @@ type AdminNetworkPolicyEgressPeer struct {
204219
// +kubebuilder:validation:XValidation:rule="self.contains(':') != self.contains('.')",message="CIDR must be either an IPv4 or IPv6 address. IPv4 address embedded in IPv6 addresses are not supported"
205220
// +kubebuilder:validation:MaxLength=43
206221
type CIDR string
222+
223+
// DomainName describes one or more domain names to be used as a peer.
224+
//
225+
// DomainName can be an exact match, or use the wildcard specifier '*' to match
226+
// one or more labels.
227+
//
228+
// '*', the wildcard specifier, matches one or more entire labels. It does not
229+
// support partial matches. '*' may only be specified as a prefix.
230+
//
231+
// Examples:
232+
// - `kubernetes.io` matches only `kubernetes.io`.
233+
// It does not match "www.kubernetes.io", "blog.kubernetes.io",
234+
// "my-kubernetes.io", or "wikipedia.org".
235+
// - `blog.kubernetes.io` matches only "blog.kubernetes.io".
236+
// It does not match "www.kubernetes.io" or "kubernetes.io".
237+
// - `*.kubernetes.io` matches subdomains of kubernetes.io.
238+
// "www.kubernetes.io", "blog.kubernetes.io", and
239+
// "latest.blog.kubernetes.io" match, however "kubernetes.io", and
240+
// "wikipedia.org" do not.
241+
//
242+
// +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])?\.?$`
243+
type DomainName string

npeps/npep-133-fqdn-egress-selector.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
* Issue:
44
[#133](https://github.com/kubernetes-sigs/network-policy-api/issues/133)
5-
* Status: Provisional
5+
* Status: Implementable
66

77
## TLDR
88

0 commit comments

Comments
 (0)