diff --git a/docs/cluster_spec.md b/docs/cluster_spec.md index 9f7f087b8b328..33996e3f885b9 100644 --- a/docs/cluster_spec.md +++ b/docs/cluster_spec.md @@ -458,6 +458,41 @@ Specifying KubeDNS will install kube-dns as the default service discovery. This will install [CoreDNS](https://coredns.io/) instead of kube-dns. +If you are using CoreDNS and want to use an entirely custom CoreFile you can do this by specifying the file. This will not work with any other options which interact with the default CoreFile. + +**Note:** If you are using this functionality you will need to be extra vigiliant on version changes of CoreDNS for changes in functionality of the plugins being used etc. + +```yaml +spec: + kubeDNS: + provider: CoreDNS + externalCoreFile: | + amazonaws.com:53 { + errors + log . { + class denial error + } + health :8084 + prometheus :9153 + proxy . 169.254.169.253 { + } + cache 30 + } + .:53 { + errors + health :8080 + autopath @kubernetes + kubernetes cluster.local { + pods verified + upstream 169.254.169.253 + fallthrough in-addr.arpa ip6.arpa + } + prometheus :9153 + proxy . 169.254.169.253 + cache 300 + } +``` + **Note:** If you are upgrading to CoreDNS, kube-dns will be left in place and must be removed manually (you can scale the kube-dns and kube-dns-autoscaler deployments in the `kube-system` namespace to 0 as a starting point). The `kube-dns` Service itself should be left in place, as this retains the ClusterIP and eliminates the possibility of DNS outages in your cluster. If you would like to continue autoscaling, update the `kube-dns-autoscaler` Deployment container command for `--target=Deployment/kube-dns` to be `--target=Deployment/coredns`. ### kubeControllerManager diff --git a/pkg/apis/kops/cluster.go b/pkg/apis/kops/cluster.go index b2ade52bb534d..bbee8d9e58856 100644 --- a/pkg/apis/kops/cluster.go +++ b/pkg/apis/kops/cluster.go @@ -356,6 +356,8 @@ type KubeDNSConfig struct { CacheMaxConcurrent int `json:"cacheMaxConcurrent,omitempty"` // Domain is the dns domain Domain string `json:"domain,omitempty"` + // ExternalCoreFile is used to provide a complete CoreDNS CoreFile by the user - ignores other provided flags which modify the CoreFile. + ExternalCoreFile string `json:"externalCoreFile,omitempty"` // Image is the name of the docker image to run - @deprecated as this is now in the addon Image string `json:"image,omitempty"` // Replicas is the number of pod replicas - @deprecated as this is now in the addon and controlled by autoscaler diff --git a/pkg/apis/kops/v1alpha1/cluster.go b/pkg/apis/kops/v1alpha1/cluster.go index 490fa10abd8be..ca727ae47e7bd 100644 --- a/pkg/apis/kops/v1alpha1/cluster.go +++ b/pkg/apis/kops/v1alpha1/cluster.go @@ -355,6 +355,8 @@ type KubeDNSConfig struct { CacheMaxConcurrent int `json:"cacheMaxConcurrent,omitempty"` // Domain is the dns domain Domain string `json:"domain,omitempty"` + // ExternalCoreFile is used to provide a complete CoreDNS CoreFile by the user - ignores other provided flags which modify the CoreFile. + ExternalCoreFile string `json:"externalCoreFile,omitempty"` // Image is the name of the docker image to run - @deprecated as this is now in the addon Image string `json:"image,omitempty"` // Replicas is the number of pod replicas - @deprecated as this is now in the addon, and controlled by autoscaler diff --git a/pkg/apis/kops/v1alpha1/zz_generated.conversion.go b/pkg/apis/kops/v1alpha1/zz_generated.conversion.go index 77e9db1619c4f..a5fe5d17b1431 100644 --- a/pkg/apis/kops/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha1/zz_generated.conversion.go @@ -3250,6 +3250,7 @@ func autoConvert_v1alpha1_KubeDNSConfig_To_kops_KubeDNSConfig(in *KubeDNSConfig, out.CacheMaxSize = in.CacheMaxSize out.CacheMaxConcurrent = in.CacheMaxConcurrent out.Domain = in.Domain + out.ExternalCoreFile = in.ExternalCoreFile out.Image = in.Image out.Replicas = in.Replicas out.Provider = in.Provider @@ -3271,6 +3272,7 @@ func autoConvert_kops_KubeDNSConfig_To_v1alpha1_KubeDNSConfig(in *kops.KubeDNSCo out.CacheMaxSize = in.CacheMaxSize out.CacheMaxConcurrent = in.CacheMaxConcurrent out.Domain = in.Domain + out.ExternalCoreFile = in.ExternalCoreFile out.Image = in.Image out.Replicas = in.Replicas out.Provider = in.Provider diff --git a/pkg/apis/kops/v1alpha2/cluster.go b/pkg/apis/kops/v1alpha2/cluster.go index 7b175440130c0..44eeb2f6af9ea 100644 --- a/pkg/apis/kops/v1alpha2/cluster.go +++ b/pkg/apis/kops/v1alpha2/cluster.go @@ -356,6 +356,8 @@ type KubeDNSConfig struct { CacheMaxConcurrent int `json:"cacheMaxConcurrent,omitempty"` // Domain is the dns domain Domain string `json:"domain,omitempty"` + // ExternalCoreFile is used to provide a complete CoreDNS CoreFile by the user - ignores other provided flags which modify the CoreFile. + ExternalCoreFile string `json:"externalCoreFile,omitempty"` // Image is the name of the docker image to run - @deprecated as this is now in the addon Image string `json:"image,omitempty"` // Replicas is the number of pod replicas - @deprecated as this is now in the addon, and controlled by autoscaler diff --git a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go index 7941096d1a38f..237ec68ebe906 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go @@ -3520,6 +3520,7 @@ func autoConvert_v1alpha2_KubeDNSConfig_To_kops_KubeDNSConfig(in *KubeDNSConfig, out.CacheMaxSize = in.CacheMaxSize out.CacheMaxConcurrent = in.CacheMaxConcurrent out.Domain = in.Domain + out.ExternalCoreFile = in.ExternalCoreFile out.Image = in.Image out.Replicas = in.Replicas out.Provider = in.Provider @@ -3541,6 +3542,7 @@ func autoConvert_kops_KubeDNSConfig_To_v1alpha2_KubeDNSConfig(in *kops.KubeDNSCo out.CacheMaxSize = in.CacheMaxSize out.CacheMaxConcurrent = in.CacheMaxConcurrent out.Domain = in.Domain + out.ExternalCoreFile = in.ExternalCoreFile out.Image = in.Image out.Replicas = in.Replicas out.Provider = in.Provider diff --git a/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.12.yaml.template b/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.12.yaml.template index 548efa25825c7..a17995341d83e 100644 --- a/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.12.yaml.template +++ b/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.12.yaml.template @@ -59,6 +59,9 @@ metadata: addonmanager.kubernetes.io/mode: EnsureExists data: Corefile: | + {{- if KubeDNS.ExternalCoreFile }} + {{ KubeDNS.ExternalCoreFile }} + {{- else }} .:53 { errors health @@ -74,6 +77,7 @@ data: loadbalance reload } + {{- end }} --- apiVersion: apps/v1 kind: Deployment diff --git a/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.6.yaml.template b/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.6.yaml.template index 618f68b888794..b14621bc859e2 100644 --- a/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.6.yaml.template +++ b/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.6.yaml.template @@ -59,6 +59,9 @@ metadata: addonmanager.kubernetes.io/mode: EnsureExists data: Corefile: | + {{- if KubeDNS.ExternalCoreFile }} + {{ KubeDNS.ExternalCoreFile }} + {{- else }} .:53 { errors health @@ -74,6 +77,7 @@ data: loadbalance reload } + {{- end }} --- apiVersion: apps/v1 kind: Deployment diff --git a/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go b/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go index 7ac0e20a4a637..a51af6ff5f970 100644 --- a/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go +++ b/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go @@ -264,7 +264,7 @@ func (b *BootstrapChannelBuilder) buildAddons() *channelsapi.Addons { if kubeDNS.Provider == "CoreDNS" { { key := "coredns.addons.k8s.io" - version := "1.3.1-kops.3" + version := "1.3.1-kops.4" { location := key + "/k8s-1.6.yaml" @@ -283,7 +283,7 @@ func (b *BootstrapChannelBuilder) buildAddons() *channelsapi.Addons { { key := "coredns.addons.k8s.io" - version := "1.3.1" + version := "1.3.1-kops.4" { location := key + "/k8s-1.12.yaml"