Skip to content

Commit

Permalink
Add nodeLocalDNSCache.kubeDnsOnly option
Browse files Browse the repository at this point in the history
  • Loading branch information
javipolo committed Oct 27, 2020
1 parent d739bae commit 52826f3
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/cluster_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ NodeLocal DNSCache can be enabled if you are using CoreDNS. It is used to improv

`memoryRequest` and `cpuRequest` for the `node-local-dns` pods can also be configured. If not set, they will be configured by default to `5Mi` and `25m` respectively.

If `forwardToKubeDNS` is enabled, kubedns will be used as a default upstream

```yaml
spec:
kubeDNS:
Expand Down
3 changes: 3 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,9 @@ spec:
enabled:
description: Enabled activates the node-local-dns addon
type: boolean
forwardToKubeDNS:
description: If enabled, nodelocal dns will use kubedns as a default upstream
type: boolean
localIP:
description: Local listen IP address. It can be any IP in the 169.254.20.0/16 space or any other IP address that can be guaranteed to not collide with any existing IP.
type: string
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ type NodeLocalDNSConfig struct {
Enabled *bool `json:"enabled,omitempty"`
// Local listen IP address. It can be any IP in the 169.254.20.0/16 space or any other IP address that can be guaranteed to not collide with any existing IP.
LocalIP string `json:"localIP,omitempty"`
// If enabled, nodelocal dns will use kubedns as a default upstream
ForwardToKubeDNS *bool `json:"forwardToKubeDNS,omitempty"`
// MemoryRequest specifies the memory requests of each node-local-dns container in the daemonset. Default 5Mi.
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest specifies the cpu requests of each node-local-dns container in the daemonset. Default 25m.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ type NodeLocalDNSConfig struct {
Enabled *bool `json:"enabled,omitempty"`
// Local listen IP address. It can be any IP in the 169.254.20.0/16 space or any other IP address that can be guaranteed to not collide with any existing IP.
LocalIP string `json:"localIP,omitempty"`
// If enabled, nodelocal dns will use kubedns as a default upstream
ForwardToKubeDNS *bool `json:"forwardToKubeDNS,omitempty"`
// MemoryRequest specifies the memory requests of each node-local-dns container in the daemonset. Default 5Mi.
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest specifies the cpu requests of each node-local-dns container in the daemonset. Default 25m.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/model/components/kubedns.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func (b *KubeDnsOptionsBuilder) BuildOptions(o interface{}) error {
if fi.BoolValue(nodeLocalDNS.Enabled) && nodeLocalDNS.LocalIP == "" {
nodeLocalDNS.LocalIP = "169.254.20.10"
}
if fi.BoolValue(nodeLocalDNS.Enabled) && nodeLocalDNS.ForwardToKubeDNS == nil {
nodeLocalDNS.ForwardToKubeDNS = fi.Bool(false)
}

if nodeLocalDNS.MemoryRequest == nil || nodeLocalDNS.MemoryRequest.IsZero() {
defaultMemoryRequest := resource.MustParse("5Mi")
Expand Down
17 changes: 16 additions & 1 deletion upup/models/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ data:
prometheus :9253
health {{ KubeDNS.NodeLocalDNS.LocalIP }}:{{ NodeLocalDNSHealthCheck }}
}
{{- if KubeDNS.NodeLocalDNS.ForwardToKubeDNS }}
.:53 {
errors
cache 30
reload
loop
bind {{ KubeDNS.NodeLocalDNS.LocalIP }}
forward . {{ NodeLocalDNSClusterIP }} {
force_tcp
}
prometheus :9253
}
{{- else }}
in-addr.arpa:53 {
errors
cache 30
Expand Down Expand Up @@ -88,6 +101,7 @@ data:
forward . __PILLAR__UPSTREAM__SERVERS__
prometheus :9253
}
{{- end }}
---
apiVersion: apps/v1
kind: DaemonSet
Expand Down Expand Up @@ -177,4 +191,4 @@ spec:
name: node-local-dns
items:
- key: Corefile
path: Corefile.base
path: Corefile.base
2 changes: 2 additions & 0 deletions vendor/github.com/googleapis/gax-go/v2/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/gophercloud/gophercloud/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 52826f3

Please sign in to comment.