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

Commit

Permalink
Allow extra Coredns configuration (#1695)
Browse files Browse the repository at this point in the history
When touching the coredns configmap a cluster upgrade will overwrite the changes. This PR introduces a way to configure the changes inside the cluster config so no need to touch manually the config
  • Loading branch information
jorge07 authored and davidmccormick committed Aug 16, 2019
1 parent 1556cc0 commit 3be6c1a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/controlplane/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func NewDefaultCluster() *Cluster {
NodesPerReplica: 16,
Min: 2,
},
ExtraCoreDNSConfig: "",
},
KubeSystemNamespaceLabels: make(map[string]string),
KubernetesDashboard: KubernetesDashboard{
Expand Down Expand Up @@ -875,6 +876,7 @@ type KubeDns struct {
NodeLocalResolverOptions []string `yaml:"nodeLocalResolverOptions"`
DeployToControllers bool `yaml:"deployToControllers"`
Autoscaler KubeDnsAutoscaler `yaml:"autoscaler"`
ExtraCoreDNSConfig string `yaml:"extraCoreDNSConfig"`
}

func (c *KubeDns) MergeIfEmpty(other KubeDns) {
Expand Down
18 changes: 18 additions & 0 deletions core/controlplane/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,24 @@ kubeDns:
},
},
},
{
conf: `
kubeDns:
provider: coredns
extraCoreDNSConfig: rewrite name substring demo.app.org app.default.svc.cluster.local
`,
kubeDns: KubeDns{
Provider: "coredns",
NodeLocalResolver: false,
DeployToControllers: false,
Autoscaler: KubeDnsAutoscaler{
CoresPerReplica: 256,
NodesPerReplica: 16,
Min: 2,
},
ExtraCoreDNSConfig: "rewrite name substring demo.app.org app.default.svc.cluster.local",
},
},
}

for _, conf := range validConfigs {
Expand Down
3 changes: 3 additions & 0 deletions core/controlplane/config/templates/cloud-config-controller
Original file line number Diff line number Diff line change
Expand Up @@ -3428,6 +3428,9 @@ write_files:
upstream
fallthrough in-addr.arpa ip6.arpa
}
{{- if and (eq .KubeDns.Provider "coredns") .KubeDns.extraCoreDNSConfig }}
{{ .KubeDns.extraCoreDNSConfig }}
{{- end }}
prometheus :9153
proxy . /etc/resolv.conf
cache 30
Expand Down
3 changes: 3 additions & 0 deletions core/root/config/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,9 @@ kubeDns:
coresPerReplica: 256
nodesPerReplica: 16
min: 2
# Allows to add extra configuration into CoreDNS config map
# extraCoreDNSConfig: |
# rewrite name substring demo.app.org app.default.svc.cluster.local

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

0 comments on commit 3be6c1a

Please sign in to comment.