diff --git a/cluster/addons/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml b/cluster/addons/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml index 3dc0f7959c9..95494214a3c 100644 --- a/cluster/addons/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml +++ b/cluster/addons/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml @@ -91,7 +91,7 @@ spec: - --namespace=kube-system - --configmap=kube-dns-autoscaler # Should keep target in sync with cluster/addons/dns/kube-dns.yaml.base - - --target=Deployment/kube-dns + - --target={{.Target}} # When cluster is using large nodes(with more cores), "coresPerReplica" should dominate. # If using small nodes, "nodesPerReplica" should dominate. - --default-params={"linear":{"coresPerReplica":256,"nodesPerReplica":16,"preventSinglePointFailure":true}} diff --git a/cluster/addons/dns/coredns.yaml.base b/cluster/addons/dns/coredns.yaml.base index c6c9f7c82dd..012ad34dca0 100644 --- a/cluster/addons/dns/coredns.yaml.base +++ b/cluster/addons/dns/coredns.yaml.base @@ -74,23 +74,26 @@ metadata: name: coredns namespace: kube-system labels: - k8s-app: coredns + k8s-app: kube-dns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: - replicas: 2 + # replicas: not specified here: + # 1. In order to make Addon Manager do not reconcile this replicas parameter. + # 2. Default is 1. + # 3. Will be tuned in real time if DNS horizontal auto-scaling is turned on. strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 selector: matchLabels: - k8s-app: coredns + k8s-app: kube-dns template: metadata: labels: - k8s-app: coredns + k8s-app: kube-dns spec: serviceAccountName: coredns tolerations: @@ -140,16 +143,16 @@ spec: apiVersion: v1 kind: Service metadata: - name: coredns + name: kube-dns namespace: kube-system labels: - k8s-app: coredns + k8s-app: kube-dns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: selector: - k8s-app: coredns + k8s-app: kube-dns clusterIP: __PILLAR__DNS__SERVER__ ports: - name: dns diff --git a/cluster/addons/dns/coredns.yaml.in b/cluster/addons/dns/coredns.yaml.in index 7e79a6905cf..5ccf70bd0cd 100644 --- a/cluster/addons/dns/coredns.yaml.in +++ b/cluster/addons/dns/coredns.yaml.in @@ -74,23 +74,26 @@ metadata: name: coredns namespace: kube-system labels: - k8s-app: coredns + k8s-app: kube-dns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: - replicas: 2 + # replicas: not specified here: + # 1. In order to make Addon Manager do not reconcile this replicas parameter. + # 2. Default is 1. + # 3. Will be tuned in real time if DNS horizontal auto-scaling is turned on. strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 selector: matchLabels: - k8s-app: coredns + k8s-app: kube-dns template: metadata: labels: - k8s-app: coredns + k8s-app: kube-dns spec: serviceAccountName: coredns tolerations: @@ -140,16 +143,16 @@ spec: apiVersion: v1 kind: Service metadata: - name: coredns + name: kube-dns namespace: kube-system labels: - k8s-app: coredns + k8s-app: kube-dns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: selector: - k8s-app: coredns + k8s-app: kube-dns clusterIP: {{ pillar['dns_server'] }} ports: - name: dns diff --git a/cluster/addons/dns/coredns.yaml.sed b/cluster/addons/dns/coredns.yaml.sed index db14e841743..d635755e770 100644 --- a/cluster/addons/dns/coredns.yaml.sed +++ b/cluster/addons/dns/coredns.yaml.sed @@ -74,23 +74,26 @@ metadata: name: coredns namespace: kube-system labels: - k8s-app: coredns + k8s-app: kube-dns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: - replicas: 2 + # replicas: not specified here: + # 1. In order to make Addon Manager do not reconcile this replicas parameter. + # 2. Default is 1. + # 3. Will be tuned in real time if DNS horizontal auto-scaling is turned on. strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 selector: matchLabels: - k8s-app: coredns + k8s-app: kube-dns template: metadata: labels: - k8s-app: coredns + k8s-app: kube-dns spec: serviceAccountName: coredns tolerations: @@ -140,16 +143,16 @@ spec: apiVersion: v1 kind: Service metadata: - name: coredns + name: kube-dns namespace: kube-system labels: - k8s-app: coredns + k8s-app: kube-dns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: selector: - k8s-app: coredns + k8s-app: kube-dns clusterIP: $DNS_SERVER_IP ports: - name: dns diff --git a/cluster/gce/gci/configure-helper.sh b/cluster/gce/gci/configure-helper.sh index a47eec002a2..b189fcd4c02 100644 --- a/cluster/gce/gci/configure-helper.sh +++ b/cluster/gce/gci/configure-helper.sh @@ -27,6 +27,8 @@ set -o pipefail readonly UUID_MNT_PREFIX="/mnt/disks/by-uuid/google-local-ssds" readonly UUID_BLOCK_PREFIX="/dev/disk/by-uuid/google-local-ssds" +readonly COREDNS_AUTOSCALER="Deployment/coredns" +readonly KUBEDNS_AUTOSCALER="Deployment/kube-dns" # Use --retry-connrefused opt only if it's supported by curl. CURL_RETRY_CONNREFUSED="" @@ -2049,6 +2051,12 @@ function setup-coredns-manifest { sed -i -e "s@{{ *pillar\['dns_domain'\] *}}@${DNS_DOMAIN}@g" "${coredns_file}" sed -i -e "s@{{ *pillar\['dns_server'\] *}}@${DNS_SERVER_IP}@g" "${coredns_file}" sed -i -e "s@{{ *pillar\['service_cluster_ip_range'\] *}}@${SERVICE_CLUSTER_IP_RANGE}@g" "${coredns_file}" + + if [[ "${ENABLE_DNS_HORIZONTAL_AUTOSCALER:-}" == "true" ]]; then + setup-addon-manifests "addons" "dns-horizontal-autoscaler" "gce" + local -r dns_autoscaler_file="${dst_dir}/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml" + sed -i'' -e "s@{{.Target}}@${COREDNS_AUTOSCALER}@g" "${dns_autoscaler_file}" + fi } # Sets up the manifests of Fluentd configmap and yamls for k8s addons. @@ -2098,6 +2106,8 @@ EOF if [[ "${ENABLE_DNS_HORIZONTAL_AUTOSCALER:-}" == "true" ]]; then setup-addon-manifests "addons" "dns-horizontal-autoscaler" "gce" + local -r dns_autoscaler_file="${dst_dir}/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml" + sed -i'' -e "s@{{.Target}}@${KUBEDNS_AUTOSCALER}@g" "${dns_autoscaler_file}" fi }