---
title: "Failing to Auto Scale Elasticsearch in Kubernetes"
description: "A schedule-driven Elasticsearch cluster run by es-operator on Kubernetes repeatedly failed to scale out for the morning peak."
url: "https://swe.quest/articles/failing-to-auto-scale-elasticsearch-in-kubernetes-c5af95622c43445d"
canonical: "https://engineering.zalando.com/posts/2024/06/failing-to-auto-scale-elasticsearch-in-kubernetes.html"
source: "Zalando Engineering"
published: "2024-06-20"
difficulty: "medium"
kind: "Incident"
reading_minutes: 6
tags: ["kubernetes","incident-response","search","capacity-planning","debugging"]
---

# Failing to Auto Scale Elasticsearch in Kubernetes

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2024-06-20, 6 min read, Incident. Original: [https://engineering.zalando.com/posts/2024/06/failing-to-auto-scale-elasticsearch-in-kubernetes.html](https://engineering.zalando.com/posts/2024/06/failing-to-auto-scale-elasticsearch-in-kubernetes.html)

## Summary

A schedule-driven Elasticsearch cluster run by es-operator on Kubernetes repeatedly failed to scale out for the morning peak. A drain retry loop ignored context cancellation, so a nightly scale-in got stuck on the last node in an availability zone because zone awareness blocked shard relocation. After a Kubernetes 1.28 upgrade reshuffled pods on ephemeral storage, a second bug surfaced: interrupted scale-ins never removed the node from cluster.routing.allocation.exclude.\_ip, leaving 'zombie' excluded nodes. Mitigations were raising the nightly node count, manually clearing the exclusion list and fixing a forgotten cronjob. Crash-safe cleanup remains an open problem, and the lesson drawn is to read the code.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)
- [Incidents & postmortems](https://swe.quest/tags/incident-response.md) (Reliability & operations)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [Capacity planning](https://swe.quest/tags/capacity-planning.md) (Reliability & operations)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)

## Prerequisites

- Kubernetes StatefulSets ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- Kubernetes operators ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- Elasticsearch shard allocation ([easy posts on Search](https://swe.quest/tags/search.md?difficulty=easy))

## Keywords

Elasticsearch, es-operator, ElasticsearchDataSet, StatefulSet, AWS availability zones, Kubernetes 1.28

## Related posts

- [Break Stuff on Purpose](https://swe.quest/articles/break-stuff-on-purpose-87dc2221ffb9f4a6.md): Slack Engineering · 2024-12-10 · Medium · 5 min read · Chaos engineering, Incidents & postmortems, Observability, SRE
  Slack's internal Kibana cluster failed in January 2024 after running out of disk, a consequence of co-locating its Elasticsearch storage on the same hosts as the application.
- [2023-03-08 incident: A deep dive into the platform-level recovery](https://swe.quest/articles/2023-03-08-incident-a-deep-dive-into-the-platform-level-recovery-ad2b07fa89f3cad4.md): Datadog Engineering · 2023-06-16 · Hard · 21 min read · Incidents & postmortems, Kubernetes, Cloud platforms, Capacity planning, Networking
  Recovering from Datadog's March 8, 2023 multi-region outage, triggered by a systemd-networkd patch on Ubuntu 22.04 that cut network connectivity for nodes running Cilium, required restoring Kubernetes clusters in a strict order: parent control planes, then child control planes hosted on parent nodes, then application nodes.
- [Migrating From Elasticsearch 7.17 to Elasticsearch 8.x: Pitfalls and Learnings](https://swe.quest/articles/migrating-from-elasticsearch-7-17-to-elasticsearch-8-x-pitfalls-and-learnings-0f126d1759a782b4.md): Zalando Engineering · 2023-11-19 · Medium · 20 min read · Search, Refactoring & migrations, Java & JVM, Testing, Vector search
  Zalando's Search & Browse team moved their multi-cluster Elasticsearch deployment from 7.17 to 8.x, mainly to get approximate kNN vector search.
- [Node.js and the tale of worker threads](https://swe.quest/articles/node-js-and-the-tale-of-worker-threads-2f7f52d719f58af7.md): Zalando Engineering · 2024-07-24 · Medium · 10 min read · JavaScript, Kubernetes, Incidents & postmortems, Debugging, Observability
  A Node.js service using cluster mode called os.cpus().length inside a Kubernetes container, which returns the host's core count, not the pod's CPU allocation.
- [How we migrated onto K8s in less than 12 months](https://swe.quest/articles/how-we-migrated-onto-k8s-in-less-than-12-months-54c705b789d0d5b3.md): Figma · 2024-08-08 · Medium · 16 min read · Kubernetes, Cloud platforms, Deployment, Resilience, Cost optimization
  Figma moved most of its core services from AWS ECS to EKS in under 12 months.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
