Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit cd68fa8

Browse files
authored
Merge pull request #1875 from kfr2/add-additionalzonecorednsconfig
Allow injection of CoreDNS configuration for non-root zones
2 parents b512f0a + 592382e commit cd68fa8

File tree

5 files changed

+47
-4
lines changed

5 files changed

+47
-4
lines changed

builtin/files/cluster.yaml.tmpl

+11-3
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ kubernetes:
12121212
selfHosting:
12131213
type: canal # either "canal" or "flannel"
12141214
typha: false # enable for type 'canal' for 50+ node clusters
1215-
# typhaResources: # control k8s resources assigned to Typha pods
1215+
# typhaResources: # control k8s resources assigned to Typha pods
12161216
# requests:
12171217
# cpu: "100m"
12181218
# memory: "100Mi"
@@ -1342,7 +1342,7 @@ kubernetesDashboard:
13421342
kubeDns:
13431343
# Define which DNS provider to use (kube-dns or coredns), default coredns.
13441344
provider: coredns
1345-
1345+
13461346
# Defines resources for the CoreDNS Deployment. Ignored if using kubedns.
13471347
# dnsDeploymentResources:
13481348
# requests:
@@ -1375,9 +1375,17 @@ kubeDns:
13751375
coresPerReplica: 256
13761376
nodesPerReplica: 16
13771377
min: 2
1378-
# Allows to add extra configuration into CoreDNS config map
1378+
# Allows addition of extra configuration into CoreDNS config map's root zone.
13791379
# extraCoreDNSConfig: |
13801380
# rewrite name substring demo.app.org app.default.svc.cluster.local
1381+
# This configuration is injected into the CoreDNS config map after the root
1382+
# zone (".") and can be used to add configuration for additional zones.
1383+
# additionalZoneCoreDNSConfig: |
1384+
# global:53 {
1385+
# errors
1386+
# cache 30
1387+
# forward . 1.2.3.4:53
1388+
# }
13811389

13821390
kubeProxy:
13831391
# Use IPVS kube-proxy mode instead of [default] iptables one (requires Kubernetes 1.9.0+ to work reliably)

builtin/files/userdata/cloud-config-controller

+3
Original file line numberDiff line numberDiff line change
@@ -3904,6 +3904,9 @@ write_files:
39043904
reload
39053905
loadbalance
39063906
}
3907+
{{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
3908+
{{ .KubeDns.AdditionalZoneCoreDNSConfig }}
3909+
{{- end }}
39073910
{{- else }}
39083911
- path: /srv/kubernetes/manifests/kube-dns-sa.yaml
39093912
content: |

pkg/api/cluster.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ func NewDefaultCluster() *Cluster {
181181
Cpu: "200m",
182182
},
183183
},
184-
ExtraCoreDNSConfig: "",
184+
ExtraCoreDNSConfig: "",
185+
AdditionalZoneCoreDNSConfig: "",
185186
},
186187
KubeSystemNamespaceLabels: make(map[string]string),
187188
KubernetesDashboard: KubernetesDashboard{

pkg/api/types.go

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ type KubeDns struct {
225225
Autoscaler KubeDnsAutoscaler `yaml:"autoscaler"`
226226
DnsDeploymentResources ComputeResources `yaml:"dnsDeploymentResources,omitempty"`
227227
ExtraCoreDNSConfig string `yaml:"extraCoreDNSConfig"`
228+
AdditionalZoneCoreDNSConfig string `yaml:"additionalZoneCoreDNSConfig"`
228229
}
229230

230231
func (c *KubeDns) MergeIfEmpty(other KubeDns) {

pkg/model/cluster_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,36 @@ kubeDns:
13821382
ExtraCoreDNSConfig: "rewrite name substring demo.app.org app.default.svc.cluster.local",
13831383
},
13841384
},
1385+
{
1386+
conf: `
1387+
kubeDns:
1388+
provider: coredns
1389+
additionalZoneCoreDNSConfig: global:53 { forward . 1.2.3.4 }
1390+
`,
1391+
kubeDns: api.KubeDns{
1392+
Provider: "coredns",
1393+
NodeLocalResolver: false,
1394+
DeployToControllers: false,
1395+
AntiAffinityAvailabilityZone: false,
1396+
TTL: 30,
1397+
Autoscaler: api.KubeDnsAutoscaler{
1398+
CoresPerReplica: 256,
1399+
NodesPerReplica: 16,
1400+
Min: 2,
1401+
},
1402+
DnsDeploymentResources: api.ComputeResources{
1403+
Requests: api.ResourceQuota{
1404+
Memory: "70Mi",
1405+
Cpu: "100m",
1406+
},
1407+
Limits: api.ResourceQuota{
1408+
Memory: "170Mi",
1409+
Cpu: "200m",
1410+
},
1411+
},
1412+
AdditionalZoneCoreDNSConfig: "global:53 { forward . 1.2.3.4 }",
1413+
},
1414+
},
13851415
}
13861416

13871417
for _, conf := range validConfigs {

0 commit comments

Comments
 (0)