Skip to content

fix: improve default readiness probe config for shutdown#204

Merged
hagaibarel merged 1 commit intocoredns:masterfrom
Jimdo:ktlo-graceful-shutdown
Mar 25, 2025
Merged

fix: improve default readiness probe config for shutdown#204
hagaibarel merged 1 commit intocoredns:masterfrom
Jimdo:ktlo-graceful-shutdown

Conversation

@hvoigt
Copy link
Copy Markdown
Contributor

@hvoigt hvoigt commented Mar 24, 2025

On shutdown coredns will wait what is configured for lameduck and continue handling connections. At the same time it will fail readiness probes.

In order to give readiness checks a chance to remove the instance from the service we need to lower the failure threshold and the interval.

This is to avoid failing DNS requests in a busy cluster when coredns is being scaled down.

Why is this pull request needed and what does it do?

We used a dns-test-container and did the following procedure to get this result:

We configured coredns as it is default by EKS lameduck 5s and readinessProbe: periodSeconds=10s failureThreshold=3

  1. Before the test we scaled coredns to 20 instances manually
  2. We started the tests and waited roughly 10 seconds
  3. We scaled coredns to 1 instance manually
  4. Waited for the test to finish

DNS losses with current configuration

This test was executed in a cluster running ~1000 pods.

With this change in place we get no losses in DNS resolution when repeating this test

DNS no losses

Which issues (if any) are related?

The issue is described above.

Checklist:

  • I have bumped the chart version according to versioning.
  • I have updated the chart changelog with all the changes that come with this pull request according to changelog.
  • Any new values are backwards compatible and/or have sensible default.
  • I have signed off all my commits as required by DCO.

Changes are automatically published when merged to main. They are not published on branches.

Note on DCO

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

On shutdown coredns will wait what is configured for lameduck and
continue handling connections. At the same time it will fail readiness
probes.

In order to give readiness checks a chance to remove the instance from
the service we need to lower the failure threshold and the interval.

This is to avoid failing DNS requests in a busy cluster when coredns is
being scaled down.

Signed-off-by: Heiko Voigt <heiko.voigt@jimdo.com>
@hagaibarel hagaibarel merged commit ed11181 into coredns:master Mar 25, 2025
2 checks passed
@hagaibarel
Copy link
Copy Markdown
Collaborator

Thanks a lot for the effort!

@youwalther65
Copy link
Copy Markdown

youwalther65 commented Jan 5, 2026

@hvoigt I don't feel, optimising readinessProbe just for shutdown with failureThreshold: 1 is the best approach.

I did similar scale-in tests from 20 to 2 coredns pods and what I found is the following:

  • set lameduck slightly larger then readinessProbe's (failureThreshold * periodSeconds)
  • set readinessProbe to something reasonable like:
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /ready
            port: 8181
            scheme: HTTP
          periodSeconds: 5
          successThreshold: 1
          timeoutSeconds: 1

Using the above readinessProbe with a lameduckof 16 or 17s worked perfectly fine and I saw no errors.

Screenshot 2026-01-05 at 16 53 48

I am aware that this comes with a downside of longer rollout and scale-in time for coredns pods, but I believe this makes more sense from an operational perspective.

Some background for this approach:
lameduck is an attribute of health plugin and used in the pod's livenessProbeand it's sole purpose regarding scale-in/shutdown is to delay shutdown for DURATION.
The readinessProbedetermines, when an endpoint is finally removed from the corresponding endpointslices object. When a pod is deleted via scale-in by replica controller, it will get a termination timestamp, but due to lameduck is still Running and could still be potentially used to serve traffic according to upstream K8s doc here:

$ kubectl get endpointslices.discovery.k8s.io -n kube-system -l=k8s-app=kube-dns -o yaml
apiVersion: v1
items:
- addressType: IPv4
  apiVersion: discovery.k8s.io/v1
  endpoints:
  - addresses:
    - <redacted>
    conditions:
      ready: false
      serving: true
      terminating: true
...

Using lameduck > (failureThreshold * periodSeconds)makes sure that coredns process is available long enough until pod is marked Ready: False, i.e. 3 unsuccessful readinessProbes.

ameukam pushed a commit to ameukam/kops that referenced this pull request Feb 25, 2026
Adopt changes from coredns/helm#204
Signed-off-by: Arnaud Meukam <ameukam@gmail.com>
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.

3 participants