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

Commit

Permalink
Merge pull request #1875 from kfr2/add-additionalzonecorednsconfig
Browse files Browse the repository at this point in the history
Allow injection of CoreDNS configuration for non-root zones
  • Loading branch information
dominicgunn authored Jun 30, 2020
2 parents b512f0a + 592382e commit cd68fa8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
14 changes: 11 additions & 3 deletions builtin/files/cluster.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ kubernetes:
selfHosting:
type: canal # either "canal" or "flannel"
typha: false # enable for type 'canal' for 50+ node clusters
# typhaResources: # control k8s resources assigned to Typha pods
# typhaResources: # control k8s resources assigned to Typha pods
# requests:
# cpu: "100m"
# memory: "100Mi"
Expand Down Expand Up @@ -1342,7 +1342,7 @@ kubernetesDashboard:
kubeDns:
# Define which DNS provider to use (kube-dns or coredns), default coredns.
provider: coredns

# Defines resources for the CoreDNS Deployment. Ignored if using kubedns.
# dnsDeploymentResources:
# requests:
Expand Down Expand Up @@ -1375,9 +1375,17 @@ kubeDns:
coresPerReplica: 256
nodesPerReplica: 16
min: 2
# Allows to add extra configuration into CoreDNS config map
# Allows addition of extra configuration into CoreDNS config map's root zone.
# extraCoreDNSConfig: |
# rewrite name substring demo.app.org app.default.svc.cluster.local
# This configuration is injected into the CoreDNS config map after the root
# zone (".") and can be used to add configuration for additional zones.
# additionalZoneCoreDNSConfig: |
# global:53 {
# errors
# cache 30
# forward . 1.2.3.4:53
# }

kubeProxy:
# Use IPVS kube-proxy mode instead of [default] iptables one (requires Kubernetes 1.9.0+ to work reliably)
Expand Down
3 changes: 3 additions & 0 deletions builtin/files/userdata/cloud-config-controller
Original file line number Diff line number Diff line change
Expand Up @@ -3904,6 +3904,9 @@ write_files:
reload
loadbalance
}
{{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
{{ .KubeDns.AdditionalZoneCoreDNSConfig }}
{{- end }}
{{- else }}
- path: /srv/kubernetes/manifests/kube-dns-sa.yaml
content: |
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ func NewDefaultCluster() *Cluster {
Cpu: "200m",
},
},
ExtraCoreDNSConfig: "",
ExtraCoreDNSConfig: "",
AdditionalZoneCoreDNSConfig: "",
},
KubeSystemNamespaceLabels: make(map[string]string),
KubernetesDashboard: KubernetesDashboard{
Expand Down
1 change: 1 addition & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ type KubeDns struct {
Autoscaler KubeDnsAutoscaler `yaml:"autoscaler"`
DnsDeploymentResources ComputeResources `yaml:"dnsDeploymentResources,omitempty"`
ExtraCoreDNSConfig string `yaml:"extraCoreDNSConfig"`
AdditionalZoneCoreDNSConfig string `yaml:"additionalZoneCoreDNSConfig"`
}

func (c *KubeDns) MergeIfEmpty(other KubeDns) {
Expand Down
30 changes: 30 additions & 0 deletions pkg/model/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,36 @@ kubeDns:
ExtraCoreDNSConfig: "rewrite name substring demo.app.org app.default.svc.cluster.local",
},
},
{
conf: `
kubeDns:
provider: coredns
additionalZoneCoreDNSConfig: global:53 { forward . 1.2.3.4 }
`,
kubeDns: api.KubeDns{
Provider: "coredns",
NodeLocalResolver: false,
DeployToControllers: false,
AntiAffinityAvailabilityZone: false,
TTL: 30,
Autoscaler: api.KubeDnsAutoscaler{
CoresPerReplica: 256,
NodesPerReplica: 16,
Min: 2,
},
DnsDeploymentResources: api.ComputeResources{
Requests: api.ResourceQuota{
Memory: "70Mi",
Cpu: "100m",
},
Limits: api.ResourceQuota{
Memory: "170Mi",
Cpu: "200m",
},
},
AdditionalZoneCoreDNSConfig: "global:53 { forward . 1.2.3.4 }",
},
},
}

for _, conf := range validConfigs {
Expand Down

0 comments on commit cd68fa8

Please sign in to comment.