Skip to content

Commit b81cd2b

Browse files
committed
feat(helm): enable dynamicZones installation via chart configuration
Refactors Helm chart to properly support dynamicZones introduced in #2102. - add k8gb.dynamicZones boolean - add configurable extraVolumes and extraVolumeMounts - extend values.schema.json - update CoreDNS ConfigMap template Dynamic zones can now be enabled declaratively through values.yaml. Signed-off-by: Michal K <kuritka@gmail.com>
1 parent 40f91b9 commit b81cd2b

File tree

8 files changed

+129
-10
lines changed

8 files changed

+129
-10
lines changed

chart/k8gb/templates/clusterrole.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ metadata:
77
labels:
88
{{ include "chart.labels" . | indent 4 }}
99
rules:
10+
{{- if .Values.k8gb.dynamicZones }}
11+
- apiGroups:
12+
- ""
13+
resources:
14+
- configmaps
15+
verbs:
16+
- list
17+
- get
18+
- update
19+
- patch
20+
resourceNames:
21+
- "coredns-dynamic"
22+
{{- end }}
1023
- apiGroups:
1124
- ""
1225
resources:

chart/k8gb/templates/coredns/cm.yaml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@ metadata:
88
{{ include "chart.labels" . | indent 4 }}
99
data:
1010
Corefile: |-
11-
{{- range .Values.k8gb.dnsZones }}
12-
{{ .loadBalancedZone }}:5353 {
11+
(k8gbplugins) {
1312
errors
1413
health
1514
{{- if $.Values.coredns.corefile.reload.enabled }}
1615
reload {{ $.Values.coredns.corefile.reload.interval }} {{ $.Values.coredns.corefile.reload.jitter }}
1716
{{- end }}
18-
{{- if .extraPlugins }}
19-
{{- range .extraPlugins }}
20-
{{ . | nindent 8 }}
21-
{{- end }}
22-
{{- end }}
2317
ready
2418
prometheus 0.0.0.0:9153
2519
forward . /etc/resolv.conf
@@ -35,8 +29,29 @@ data:
3529
{{- end }}
3630
}
3731
}
32+
{{- range .Values.k8gb.dnsZones }}
33+
{{ .loadBalancedZone }}:5353 {
34+
import k8gbplugins
35+
{{- if .extraPlugins }}
36+
{{- range .extraPlugins }}
37+
{{ . | nindent 8 }}
38+
{{- end }}
39+
{{- end }}
40+
}
41+
{{- end }}
42+
{{- with .extraServerBlocks -}}
43+
{{- tpl . $ | nindent 4 }}
44+
{{- end }}
45+
{{- if .Values.k8gb.dynamicZones }}
46+
import ../dynamic/*.conf
3847
{{- end }}
39-
{{- with .extraServerBlocks -}}
40-
{{- tpl . $ | nindent 4 }}
41-
{{- end }}
48+
{{- end }}
49+
---
50+
{{- if .Values.k8gb.dynamicZones }}
51+
apiVersion: v1
52+
kind: ConfigMap
53+
metadata:
54+
name: coredns-dynamic
55+
namespace: {{ .Release.Namespace }}
56+
data: {}
4257
{{- end }}

chart/k8gb/templates/crds-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
{{- $files := .Files }}
44
{{ $files.Get "crd/k8gb.absa.oss_gslbs.yaml" }}
5+
{{ $files.Get "k8gb.k8gb.io_dynamiczones.yaml" }}
56

67
{{- if not .Values.extdns.enabled }}
78
{{ $files.Get "crd/dns-endpoint-crd-manifest.yaml" }}

chart/k8gb/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ spec:
142142
value: "true"
143143
- name: METRICS_ADDRESS
144144
value: {{ .Values.k8gb.metricsAddress }}
145+
- name: DYNAMIC_ZONES
146+
value: {{ .Values.k8gb.dynamicZones | quote }}
145147
{{- if .Values.tracing.enabled }}
146148
- image: {{ .Values.tracing.sidecarImage.repository }}:{{ .Values.tracing.sidecarImage.tag }}
147149
name: otel-collector

chart/k8gb/values.schema.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,70 @@
342342
"deployRbac": {
343343
"type": "boolean"
344344
},
345+
"dynamicZones": {
346+
"type": "boolean"
347+
},
348+
"extraVolumeMounts": {
349+
"type": "array",
350+
"items": {
351+
"type": "object",
352+
"required": ["name", "mountPath"],
353+
"properties": {
354+
"name": {
355+
"type": "string"
356+
},
357+
"mountPath": {
358+
"type": "string"
359+
},
360+
"readOnly": {
361+
"type": "boolean"
362+
},
363+
"subPath": {
364+
"type": "string"
365+
}
366+
},
367+
"additionalProperties": false
368+
}
369+
},
370+
"extraVolumes": {
371+
"type": "array",
372+
"items": {
373+
"type": "object",
374+
"required": ["name"],
375+
"properties": {
376+
"name": {
377+
"type": "string"
378+
},
379+
"configMap": {
380+
"type": "object",
381+
"required": ["name"],
382+
"properties": {
383+
"name": {
384+
"type": "string"
385+
},
386+
"optional": {
387+
"type": "boolean"
388+
}
389+
},
390+
"additionalProperties": false
391+
},
392+
"secret": {
393+
"type": "object",
394+
"required": ["secretName"],
395+
"properties": {
396+
"secretName": {
397+
"type": "string"
398+
},
399+
"optional": {
400+
"type": "boolean"
401+
}
402+
},
403+
"additionalProperties": false
404+
}
405+
},
406+
"additionalProperties": false
407+
}
408+
},
345409
"dnsZones": {
346410
"type": "array",
347411
"items": {

chart/k8gb/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ k8gb:
1313
deployCrds: true
1414
# -- whether it should also deploy the service account, cluster role and cluster role binding
1515
deployRbac: true
16+
# -- whether to use Dynamic Zone Delegation feature
17+
dynamicZones: false
18+
# -- dynamic zones configmap
19+
extraVolumeMounts:
20+
- name: dynamic-zones
21+
mountPath: /etc/dynamic
22+
extraVolumes:
23+
- name: dynamic-zones
24+
configMap:
25+
name: coredns-dynamic
26+
optional: true
1627
# DNSZones - For backward compatibility, the dnsZone and edgeDNSZone fields are allowed; otherwise,
1728
# the dnsZones array is used. For valid values, use either dnsZone and edgeDNSZone or dnsZones.
1829
#

controllers/resolver/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ type Config struct {
5555

5656
MetricsAddress string `env:"METRICS_ADDRESS" optional:"" default:"0.0.0.0:8080" validate:"iphostport" help:"format address:port where address can be empty, IP address, or hostname, e.g: 10.10.0.0:8080"`
5757

58+
DynamicZones bool `env:"DYNAMIC_ZONES" optional:"" default:"false" help:"decides whether to use dynamic zones"`
59+
5860
TracingEnabled bool `env:"TRACING_ENABLED" optional:"" default:"false" help:"decides whether to use a real otlp tracer or a noop one"`
5961

6062
TracingSamplingRatio float64 `env:"TRACING_SAMPLING_RATIO" optionl:"" default:"1.0" help:"how many traces should be kept and sent (1.0 - all, 0.0 - none)"`

deploy/helm/next.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
k8gb:
22
reconcileRequeueSeconds: 10
3+
4+
dynamicZones: false
5+
extraVolumeMounts:
6+
- name: dynamic-zones
7+
mountPath: /etc/dynamic
8+
extraVolumes:
9+
- name: dynamic-zones
10+
configMap:
11+
name: coredns-dynamic
12+
optional: true
13+
314
dnsZones:
415
- dnsZoneNegTTL: 10
516
loadBalancedZone: cloud.example.com

0 commit comments

Comments
 (0)