Skip to content

Enable auto-scaling for CoreDNS pods#1351

Merged
jjnesbitt merged 2 commits into
mainfrom
improve-coredns
May 1, 2026
Merged

Enable auto-scaling for CoreDNS pods#1351
jjnesbitt merged 2 commits into
mainfrom
improve-coredns

Conversation

@jjnesbitt
Copy link
Copy Markdown
Collaborator

The goal of this is to reduce flakiness in host name resolution by ensuring that CoreDNS isn't overloaded.

@jjnesbitt jjnesbitt marked this pull request as ready for review May 1, 2026 16:43
@jjnesbitt jjnesbitt changed the title Increase CoreDNS replica count and resources Enable auto-scaling for CoreDNS pods May 1, 2026
@jjnesbitt jjnesbitt requested a review from zackgalbreath May 1, 2026 16:44
@jjnesbitt
Copy link
Copy Markdown
Collaborator Author

This is successfully applied in staging. I have not yet applied it to production as terraform wants to upgrade the eks managed node group version (even though i'm not targeting that resource), which would be disruptive to the cluster.

@zackgalbreath
Copy link
Copy Markdown
Collaborator

I followed the link to the docs mentioned in this change (and locally ran the suggested command) and I didn't see any mention of an autoScaling configuration option. Where did you find this setting?

@jjnesbitt
Copy link
Copy Markdown
Collaborator Author

I followed the link to the docs mentioned in this change (and locally ran the suggested command) and I didn't see any mention of an autoScaling configuration option. Where did you find this setting?

It appears that field was added in a newer version of the configuration. Using the command they mention to pull the configuration we're using (based on our addon version), returns a config that contains that field.

{
  "$ref": "#/definitions/Coredns",
  "$schema": "http://json-schema.org/draft-06/schema#",
  "definitions": {
    "Coredns": {
      "additionalProperties": false,
      "properties": {
        "affinity": {
          "default": {
            "affinity": {
              "nodeAffinity": {
                "requiredDuringSchedulingIgnoredDuringExecution": {
                  "nodeSelectorTerms": [
                    {
                      "matchExpressions": [
                        {
                          "key": "kubernetes.io/os",
                          "operator": "In",
                          "values": [
                            "linux"
                          ]
                        },
                        {
                          "key": "kubernetes.io/arch",
                          "operator": "In",
                          "values": [
                            "amd64",
                            "arm64"
                          ]
                        }
                      ]
                    }
                  ]
                }
              },
              "podAntiAffinity": {
                "preferredDuringSchedulingIgnoredDuringExecution": [
                  {
                    "podAffinityTerm": {
                      "labelSelector": {
                        "matchExpressions": [
                          {
                            "key": "k8s-app",
                            "operator": "In",
                            "values": [
                              "kube-dns"
                            ]
                          }
                        ]
                      },
                      "topologyKey": "kubernetes.io/hostname"
                    },
                    "weight": 100
                  }
                ]
              }
            }
          },
          "description": "Affinity of the coredns pods",
          "type": [
            "object",
            "null"
          ]
        },
        "annotationTopologyMode": {
          "description": "Topology mode for annotations",
          "enum": [
            "Disabled",
            "Auto"
          ],
          "type": "string"
        },
        "autoScaling": {
          "additionalProperties": false,
          "description": "autoScaling configurations",
          "properties": {
            "enabled": {
              "default": false,
              "description": "the option to enable eks managed autoscaling for coredns",
              "type": "boolean"
            },
            "maxReplicas": {
              "description": "the max value that autoscaler can scale up the coredns replicas to",
              "maximum": 1000,
              "minimum": 2,
              "type": "integer"
            },
            "minReplicas": {
              "default": 2,
              "description": "the min value that autoscaler can scale down the coredns replicas to",
              "maximum": 1000,
              "minimum": 2,
              "type": "integer"
            }
          },
          "required": [
            "enabled"
          ],
          "type": "object"
        },
        "computeType": {
          "type": "string"
        },
        "corefile": {
          "description": "Entire corefile contents to use with installation",
          "type": "string"
        },
        "nodeSelector": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        "podAnnotations": {
          "properties": {},
          "title": "The podAnnotations Schema",
          "type": "object"
        },
        "podDisruptionBudget": {
          "description": "podDisruptionBudget configurations",
          "properties": {
            "enabled": {
              "default": true,
              "description": "the option to enable managed PDB",
              "type": "boolean"
            },
            "maxUnavailable": {
              "anyOf": [
                {
                  "pattern": ".*%$",
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ],
              "default": 1,
              "description": "maxUnavailable value for managed PDB, can be either string or integer; if it's string, should end with %"
            },
            "minAvailable": {
              "anyOf": [
                {
                  "pattern": ".*%$",
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ],
              "description": "minAvailable value for managed PDB, can be either string or integer; if it's string, should end with %"
            }
          },
          "type": "object"
        },
        "podLabels": {
          "properties": {},
          "title": "The podLabels Schema",
          "type": "object"
        },
        "replicaCount": {
          "type": "integer"
        },
        "resources": {
          "$ref": "#/definitions/Resources"
        },
        "tolerations": {
          "default": [
            {
              "key": "CriticalAddonsOnly",
              "operator": "Exists"
            },
            {
              "effect": "NoSchedule",
              "key": "node-role.kubernetes.io/control-plane"
            }
          ],
          "description": "Tolerations of the coredns pod",
          "items": {
            "type": "object"
          },
          "type": "array"
        },
        "topologySpreadConstraints": {
          "description": "The coredns pod topology spread constraints",
          "type": "array"
        }
      },
      "title": "Coredns",
      "type": "object"
    },
    "Limits": {
      "additionalProperties": false,
      "properties": {
        "cpu": {
          "type": "string"
        },
        "memory": {
          "type": "string"
        }
      },
      "title": "Limits",
      "type": "object"
    },
    "Resources": {
      "additionalProperties": false,
      "properties": {
        "limits": {
          "$ref": "#/definitions/Limits"
        },
        "requests": {
          "$ref": "#/definitions/Limits"
        }
      },
      "title": "Resources",
      "type": "object"
    }
  }
}

@jjnesbitt
Copy link
Copy Markdown
Collaborator Author

I've just applied this successfully in prod.

@jjnesbitt jjnesbitt merged commit 822d4dc into main May 1, 2026
5 checks passed
@jjnesbitt jjnesbitt deleted the improve-coredns branch May 1, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants