Skip to content

Commit 8ab2480

Browse files
committed
make changes for reconcile logic and remove cel validation for overrides
1 parent 3f7db6e commit 8ab2480

File tree

4 files changed

+150
-62
lines changed

4 files changed

+150
-62
lines changed

charts/karpenter-crd/templates/karpenter.azure.com_aksnodeclasses.yaml

Lines changed: 76 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@ spec:
188188
For more details see aka.ms/aks/localdns.
189189
properties:
190190
kubeDNSOverrides:
191-
additionalProperties:
192-
description: LocalDNSOverrides specifies DNS override configuration
191+
description: KubeDNS overrides apply to DNS traffic from pods
192+
with dnsPolicy:ClusterFirst (referred to as KubeDNS traffic).
193+
items:
194+
description: LocalDNSZoneOverride specifies DNS override configuration
195+
for a specific zone
193196
properties:
194197
cacheDuration:
195198
description: Cache max TTL. See [cache plugin](https://coredns.io/plugins/cache)
@@ -244,6 +247,10 @@ spec:
244247
for more information.
245248
pattern: ^([0-9]+(s|m|h))+$
246249
type: string
250+
zone:
251+
description: Zone is the DNS zone this override applies
252+
to (e.g., ".", "cluster.local").
253+
type: string
247254
required:
248255
- cacheDuration
249256
- forwardDestination
@@ -253,14 +260,16 @@ spec:
253260
- queryLogging
254261
- serveStale
255262
- serveStaleDuration
263+
- zone
256264
type: object
257265
x-kubernetes-validations:
258266
- message: ServeStale verify cannot be used with ForceTCP protocol
259267
rule: '!(has(self.serveStale) && self.serveStale == ''Verify''
260268
&& has(self.protocol) && self.protocol == ''ForceTCP'')'
261-
description: KubeDNS overrides apply to DNS traffic from pods
262-
with dnsPolicy:ClusterFirst (referred to as KubeDNS traffic).
263-
type: object
269+
type: array
270+
x-kubernetes-validations:
271+
- message: each zone must be unique in kubeDNSOverrides
272+
rule: self.all(o, self.exists_one(p, p.zone == o.zone))
264273
mode:
265274
description: Mode of enablement for localDNS.
266275
enum:
@@ -269,8 +278,11 @@ spec:
269278
- Disabled
270279
type: string
271280
vnetDNSOverrides:
272-
additionalProperties:
273-
description: LocalDNSOverrides specifies DNS override configuration
281+
description: VnetDNS overrides apply to DNS traffic from pods
282+
with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
283+
items:
284+
description: LocalDNSZoneOverride specifies DNS override configuration
285+
for a specific zone
274286
properties:
275287
cacheDuration:
276288
description: Cache max TTL. See [cache plugin](https://coredns.io/plugins/cache)
@@ -325,6 +337,10 @@ spec:
325337
for more information.
326338
pattern: ^([0-9]+(s|m|h))+$
327339
type: string
340+
zone:
341+
description: Zone is the DNS zone this override applies
342+
to (e.g., ".", "cluster.local").
343+
type: string
328344
required:
329345
- cacheDuration
330346
- forwardDestination
@@ -334,38 +350,40 @@ spec:
334350
- queryLogging
335351
- serveStale
336352
- serveStaleDuration
353+
- zone
337354
type: object
338355
x-kubernetes-validations:
339356
- message: ServeStale verify cannot be used with ForceTCP protocol
340357
rule: '!(has(self.serveStale) && self.serveStale == ''Verify''
341358
&& has(self.protocol) && self.protocol == ''ForceTCP'')'
342-
description: VnetDNS overrides apply to DNS traffic from pods
343-
with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
344-
type: object
359+
type: array
360+
x-kubernetes-validations:
361+
- message: each zone must be unique in vnetDNSOverrides
362+
rule: self.all(o, self.exists_one(p, p.zone == o.zone))
345363
required:
346364
- kubeDNSOverrides
347365
- mode
348366
- vnetDNSOverrides
349367
type: object
350368
x-kubernetes-validations:
351369
- message: vnetDNSOverrides must contain required zones '.' and 'cluster.local'
352-
rule: '''.'' in self.vnetDNSOverrides && ''cluster.local'' in self.vnetDNSOverrides'
370+
rule: self.vnetDNSOverrides.exists(o, o.zone == '.') && self.vnetDNSOverrides.exists(o,
371+
o.zone == 'cluster.local')
353372
- message: kubeDNSOverrides must contain required zones '.' and 'cluster.local'
354-
rule: '''.'' in self.kubeDNSOverrides && ''cluster.local'' in self.kubeDNSOverrides'
373+
rule: self.kubeDNSOverrides.exists(o, o.zone == '.') && self.kubeDNSOverrides.exists(o,
374+
o.zone == 'cluster.local')
355375
- message: DNS traffic for root zone '.' cannot be forwarded to ClusterCoreDNS
356376
from vnetDNSOverrides
357-
rule: '!(''.'' in self.vnetDNSOverrides && has(self.vnetDNSOverrides[''.''].forwardDestination)
358-
&& self.vnetDNSOverrides[''.''].forwardDestination == ''ClusterCoreDNS'')'
377+
rule: '!self.vnetDNSOverrides.exists(o, o.zone == ''.'' && has(o.forwardDestination)
378+
&& o.forwardDestination == ''ClusterCoreDNS'')'
359379
- message: DNS traffic for 'cluster.local' cannot be forwarded to
360380
VnetDNS from vnetDNSOverrides
361-
rule: '!self.vnetDNSOverrides.exists(zone, zone.endsWith(''cluster.local'')
362-
&& has(self.vnetDNSOverrides[zone].forwardDestination) && self.vnetDNSOverrides[zone].forwardDestination
363-
== ''VnetDNS'')'
381+
rule: '!self.vnetDNSOverrides.exists(o, o.zone.endsWith(''cluster.local'')
382+
&& has(o.forwardDestination) && o.forwardDestination == ''VnetDNS'')'
364383
- message: DNS traffic for 'cluster.local' cannot be forwarded to
365384
VnetDNS from kubeDNSOverrides
366-
rule: '!self.kubeDNSOverrides.exists(zone, zone.endsWith(''cluster.local'')
367-
&& has(self.kubeDNSOverrides[zone].forwardDestination) && self.kubeDNSOverrides[zone].forwardDestination
368-
== ''VnetDNS'')'
385+
rule: '!self.kubeDNSOverrides.exists(o, o.zone.endsWith(''cluster.local'')
386+
&& has(o.forwardDestination) && o.forwardDestination == ''VnetDNS'')'
369387
maxPods:
370388
description: |-
371389
MaxPods is an override for the maximum number of pods that can run on a worker node instance.
@@ -711,8 +729,11 @@ spec:
711729
For more details see aka.ms/aks/localdns.
712730
properties:
713731
kubeDNSOverrides:
714-
additionalProperties:
715-
description: LocalDNSOverrides specifies DNS override configuration
732+
description: KubeDNS overrides apply to DNS traffic from pods
733+
with dnsPolicy:ClusterFirst (referred to as KubeDNS traffic).
734+
items:
735+
description: LocalDNSZoneOverride specifies DNS override configuration
736+
for a specific zone
716737
properties:
717738
cacheDuration:
718739
description: Cache max TTL. See [cache plugin](https://coredns.io/plugins/cache)
@@ -767,6 +788,10 @@ spec:
767788
for more information.
768789
pattern: ^([0-9]+(s|m|h))+$
769790
type: string
791+
zone:
792+
description: Zone is the DNS zone this override applies
793+
to (e.g., ".", "cluster.local").
794+
type: string
770795
required:
771796
- cacheDuration
772797
- forwardDestination
@@ -776,14 +801,16 @@ spec:
776801
- queryLogging
777802
- serveStale
778803
- serveStaleDuration
804+
- zone
779805
type: object
780806
x-kubernetes-validations:
781807
- message: ServeStale verify cannot be used with ForceTCP protocol
782808
rule: '!(has(self.serveStale) && self.serveStale == ''Verify''
783809
&& has(self.protocol) && self.protocol == ''ForceTCP'')'
784-
description: KubeDNS overrides apply to DNS traffic from pods
785-
with dnsPolicy:ClusterFirst (referred to as KubeDNS traffic).
786-
type: object
810+
type: array
811+
x-kubernetes-validations:
812+
- message: each zone must be unique in kubeDNSOverrides
813+
rule: self.all(o, self.exists_one(p, p.zone == o.zone))
787814
mode:
788815
description: Mode of enablement for localDNS.
789816
enum:
@@ -792,8 +819,11 @@ spec:
792819
- Disabled
793820
type: string
794821
vnetDNSOverrides:
795-
additionalProperties:
796-
description: LocalDNSOverrides specifies DNS override configuration
822+
description: VnetDNS overrides apply to DNS traffic from pods
823+
with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
824+
items:
825+
description: LocalDNSZoneOverride specifies DNS override configuration
826+
for a specific zone
797827
properties:
798828
cacheDuration:
799829
description: Cache max TTL. See [cache plugin](https://coredns.io/plugins/cache)
@@ -848,6 +878,10 @@ spec:
848878
for more information.
849879
pattern: ^([0-9]+(s|m|h))+$
850880
type: string
881+
zone:
882+
description: Zone is the DNS zone this override applies
883+
to (e.g., ".", "cluster.local").
884+
type: string
851885
required:
852886
- cacheDuration
853887
- forwardDestination
@@ -857,38 +891,40 @@ spec:
857891
- queryLogging
858892
- serveStale
859893
- serveStaleDuration
894+
- zone
860895
type: object
861896
x-kubernetes-validations:
862897
- message: ServeStale verify cannot be used with ForceTCP protocol
863898
rule: '!(has(self.serveStale) && self.serveStale == ''Verify''
864899
&& has(self.protocol) && self.protocol == ''ForceTCP'')'
865-
description: VnetDNS overrides apply to DNS traffic from pods
866-
with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
867-
type: object
900+
type: array
901+
x-kubernetes-validations:
902+
- message: each zone must be unique in vnetDNSOverrides
903+
rule: self.all(o, self.exists_one(p, p.zone == o.zone))
868904
required:
869905
- kubeDNSOverrides
870906
- mode
871907
- vnetDNSOverrides
872908
type: object
873909
x-kubernetes-validations:
874910
- message: vnetDNSOverrides must contain required zones '.' and 'cluster.local'
875-
rule: '''.'' in self.vnetDNSOverrides && ''cluster.local'' in self.vnetDNSOverrides'
911+
rule: self.vnetDNSOverrides.exists(o, o.zone == '.') && self.vnetDNSOverrides.exists(o,
912+
o.zone == 'cluster.local')
876913
- message: kubeDNSOverrides must contain required zones '.' and 'cluster.local'
877-
rule: '''.'' in self.kubeDNSOverrides && ''cluster.local'' in self.kubeDNSOverrides'
914+
rule: self.kubeDNSOverrides.exists(o, o.zone == '.') && self.kubeDNSOverrides.exists(o,
915+
o.zone == 'cluster.local')
878916
- message: DNS traffic for root zone '.' cannot be forwarded to ClusterCoreDNS
879917
from vnetDNSOverrides
880-
rule: '!(''.'' in self.vnetDNSOverrides && has(self.vnetDNSOverrides[''.''].forwardDestination)
881-
&& self.vnetDNSOverrides[''.''].forwardDestination == ''ClusterCoreDNS'')'
918+
rule: '!self.vnetDNSOverrides.exists(o, o.zone == ''.'' && has(o.forwardDestination)
919+
&& o.forwardDestination == ''ClusterCoreDNS'')'
882920
- message: DNS traffic for 'cluster.local' cannot be forwarded to
883921
VnetDNS from vnetDNSOverrides
884-
rule: '!self.vnetDNSOverrides.exists(zone, zone.endsWith(''cluster.local'')
885-
&& has(self.vnetDNSOverrides[zone].forwardDestination) && self.vnetDNSOverrides[zone].forwardDestination
886-
== ''VnetDNS'')'
922+
rule: '!self.vnetDNSOverrides.exists(o, o.zone.endsWith(''cluster.local'')
923+
&& has(o.forwardDestination) && o.forwardDestination == ''VnetDNS'')'
887924
- message: DNS traffic for 'cluster.local' cannot be forwarded to
888925
VnetDNS from kubeDNSOverrides
889-
rule: '!self.kubeDNSOverrides.exists(zone, zone.endsWith(''cluster.local'')
890-
&& has(self.kubeDNSOverrides[zone].forwardDestination) && self.kubeDNSOverrides[zone].forwardDestination
891-
== ''VnetDNS'')'
926+
rule: '!self.kubeDNSOverrides.exists(o, o.zone.endsWith(''cluster.local'')
927+
&& has(o.forwardDestination) && o.forwardDestination == ''VnetDNS'')'
892928
maxPods:
893929
description: |-
894930
MaxPods is an override for the maximum number of pods that can run on a worker node instance.

pkg/apis/v1alpha2/aksnodeclass.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,14 @@ const (
118118
// LocalDNS configures the per-node local DNS, with VnetDNS and KubeDNS overrides.
119119
// LocalDNS helps improve performance and reliability of DNS resolution in an AKS cluster.
120120
// For more details see aka.ms/aks/localdns.
121-
// +kubebuilder:validation:XValidation:rule="self.vnetDNSOverrides.exists(o, o.zone == '.') && self.vnetDNSOverrides.exists(o, o.zone == 'cluster.local')",message="vnetDNSOverrides must contain required zones '.' and 'cluster.local'"
122-
// +kubebuilder:validation:XValidation:rule="self.kubeDNSOverrides.exists(o, o.zone == '.') && self.kubeDNSOverrides.exists(o, o.zone == 'cluster.local')",message="kubeDNSOverrides must contain required zones '.' and 'cluster.local'"
123-
// +kubebuilder:validation:XValidation:rule="!self.vnetDNSOverrides.exists(o, o.zone == '.' && has(o.forwardDestination) && o.forwardDestination == 'ClusterCoreDNS')",message="DNS traffic for root zone '.' cannot be forwarded to ClusterCoreDNS from vnetDNSOverrides"
124-
// +kubebuilder:validation:XValidation:rule="!self.vnetDNSOverrides.exists(o, o.zone.endsWith('cluster.local') && has(o.forwardDestination) && o.forwardDestination == 'VnetDNS')",message="DNS traffic for 'cluster.local' cannot be forwarded to VnetDNS from vnetDNSOverrides"
125-
// +kubebuilder:validation:XValidation:rule="!self.kubeDNSOverrides.exists(o, o.zone.endsWith('cluster.local') && has(o.forwardDestination) && o.forwardDestination == 'VnetDNS')",message="DNS traffic for 'cluster.local' cannot be forwarded to VnetDNS from kubeDNSOverrides"
126121
type LocalDNS struct {
127122
// Mode of enablement for localDNS.
128123
// +required
129124
Mode LocalDNSMode `json:"mode"`
130125
// VnetDNS overrides apply to DNS traffic from pods with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
131-
// +kubebuilder:validation:XValidation:rule="self.all(o, self.exists_one(p, p.zone == o.zone))",message="each zone must be unique in vnetDNSOverrides"
132126
// +required
133127
VnetDNSOverrides []LocalDNSZoneOverride `json:"vnetDNSOverrides"`
134128
// KubeDNS overrides apply to DNS traffic from pods with dnsPolicy:ClusterFirst (referred to as KubeDNS traffic).
135-
// +kubebuilder:validation:XValidation:rule="self.all(o, self.exists_one(p, p.zone == o.zone))",message="each zone must be unique in kubeDNSOverrides"
136129
// +required
137130
KubeDNSOverrides []LocalDNSZoneOverride `json:"kubeDNSOverrides"`
138131
}

pkg/apis/v1beta1/aksnodeclass.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,14 @@ const (
119119
// LocalDNS configures the per-node local DNS, with VnetDNS and KubeDNS overrides.
120120
// LocalDNS helps improve performance and reliability of DNS resolution in an AKS cluster.
121121
// For more details see aka.ms/aks/localdns.
122-
// +kubebuilder:validation:XValidation:rule="self.vnetDNSOverrides.exists(o, o.zone == '.') && self.vnetDNSOverrides.exists(o, o.zone == 'cluster.local')",message="vnetDNSOverrides must contain required zones '.' and 'cluster.local'"
123-
// +kubebuilder:validation:XValidation:rule="self.kubeDNSOverrides.exists(o, o.zone == '.') && self.kubeDNSOverrides.exists(o, o.zone == 'cluster.local')",message="kubeDNSOverrides must contain required zones '.' and 'cluster.local'"
124-
// +kubebuilder:validation:XValidation:rule="!self.vnetDNSOverrides.exists(o, o.zone == '.' && has(o.forwardDestination) && o.forwardDestination == 'ClusterCoreDNS')",message="DNS traffic for root zone '.' cannot be forwarded to ClusterCoreDNS from vnetDNSOverrides"
125-
// +kubebuilder:validation:XValidation:rule="!self.vnetDNSOverrides.exists(o, o.zone.endsWith('cluster.local') && has(o.forwardDestination) && o.forwardDestination == 'VnetDNS')",message="DNS traffic for 'cluster.local' cannot be forwarded to VnetDNS from vnetDNSOverrides"
126-
// +kubebuilder:validation:XValidation:rule="!self.kubeDNSOverrides.exists(o, o.zone.endsWith('cluster.local') && has(o.forwardDestination) && o.forwardDestination == 'VnetDNS')",message="DNS traffic for 'cluster.local' cannot be forwarded to VnetDNS from kubeDNSOverrides"
127122
type LocalDNS struct {
128123
// Mode of enablement for localDNS.
129124
// +required
130125
Mode LocalDNSMode `json:"mode"`
131126
// VnetDNS overrides apply to DNS traffic from pods with dnsPolicy:default or kubelet (referred to as VnetDNS traffic).
132-
// +kubebuilder:validation:XValidation:rule="self.all(o, self.exists_one(p, p.zone == o.zone))",message="each zone must be unique in vnetDNSOverrides"
133127
// +required
134128
VnetDNSOverrides []LocalDNSZoneOverride `json:"vnetDNSOverrides"`
135129
// KubeDNS overrides apply to DNS traffic from pods with dnsPolicy:ClusterFirst (referred to as KubeDNS traffic).
136-
// +kubebuilder:validation:XValidation:rule="self.all(o, self.exists_one(p, p.zone == o.zone))",message="each zone must be unique in kubeDNSOverrides"
137130
// +required
138131
KubeDNSOverrides []LocalDNSZoneOverride `json:"kubeDNSOverrides"`
139132
}

0 commit comments

Comments
 (0)