Skip to main content
What has grown too small? Bob opens his Grafana panels to investigate, and the picture is clear. Three months ago the application produced only a few log lines a minute.
A dark-themed slide titled "What Has Grown Too Small" with a circular avatar labeled "Bob" on the left. To the right is a card labeled "Log lines" showing a mostly flat blue trend line from "3 months ago" to "Now."
Now more apps share the cluster and the log lines pour in, but the EFK stack is still the same size it was on day one. From the team’s point of view the symptoms are obvious:
  • Discover searches take a long time to return results.
  • Newest log lines appear with several minutes of delay.
Example: a simple activity stream that should appear near-instantly instead lags:
On the busiest node one Fluentd pod is reading a rapidly growing file while the single Elasticsearch pod (elasticsearch-0) has CPU pegged. What can Bob actually change to recover search speed and lower ingestion lag? Two high-level directions exist: make a pod bigger (vertical scaling) or add more pods (horizontal scaling). Both are valid and often used together.
A dark-themed illustration titled "Two Ways to Grow" showing two isometric platforms—one labeled "controlplane" and the other hosting a glowing orange robot-like icon. A small CPU line chart is on the right and the KodeKloud logo appears in the bottom-left.

Vertical scaling (make a pod larger)

Vertical scaling is straightforward to understand. In Kubernetes you set container resource requests and limits. The scheduler reserves CPU/memory based on requests, and the runtime enforces limits. Example:
  • cpu: "250m" → 250 millicores (0.25 CPU) requested
  • cpu: "500m" → 500 millicores (0.5 CPU) limit
Example Elasticsearch container resources:
Vertical scaling is quick but limited by node size: a pod cannot exceed the resources of the node it runs on.

Horizontal scaling (add more pods)

Start with Fluentd. A DaemonSet ensures one Fluentd pod per node, so newly added nodes automatically get a collector. But that doesn’t help when a single node is noisy and produces far more logs than others.
An infographic titled "One Fluentd per Node" showing three server nodes labeled controlplane, node01 (both with glowing Fluentd mascots) and node02 (empty). The diagram also displays the word "DaemonSet" and a small KodeKloud logo in the corner.
To collect from one busy node you can deploy additional Fluentd pods targeted at that node (for example via nodeSelector or nodeAffinity) so they run alongside the DaemonSet pod. Example Deployment to add two extra collectors on nodes labeled logging=busy:
While Elasticsearch is slow, Fluentd buffers and retries (rather than dropping lines immediately). Buffers can live in memory or on disk and are sent in chunks. Tuning buffer size, flush frequency, and retry behavior lets Fluentd absorb bursts while Elasticsearch catches up.
A dark-themed slide titled "Tuning the Buffer" with a central stacked buffer graphic labeled "2M" flanked by two glowing blue robot/server mascots.
Example Fluentd buffer section (ConfigMap snippet):
Tuning these helps Fluentd ride through temporary Elasticsearch slowness.

Can you add more Elasticsearch pods?

You can only add more Elasticsearch pods to gain parallelism if the data can be split across shards. Right now Bob’s Fluentd index uses a single primary shard: number_of_shards: 1. A second Elasticsearch pod would have no shard to host, so the cluster wouldn’t get parallelism for that index. Elasticsearch uses shards to distribute an index. To change the shard count for existing data you typically:
  1. Create a new index configured with the desired number of primary shards.
  2. Reindex data from the old index into the new index using the Reindex API.
  3. Verify, switch aliases, and remove the old index.
A dark-themed infographic titled "Can the Data Be Split" with a rounded progress bar labeled "fluentd index" near the top and a small blue robot mascot standing on a platform holding a circular logo at the bottom left.
Example: create a new index with 5 primary shards and 1 replica:
Then reindex from the old index into the new one:
You cannot change the number of primary shards for an existing index in place. Reindexing moves data into a new index and can be resource-intensive; plan reindex windows, replica settings, and shard allocation accordingly. Always snapshot before major index operations.

Handle fluctuating load with autoscaling

Load often fluctuates (for example high during daytime, low at night). Manually adjusting pods around the clock is impractical. Kubernetes can autoscale pods if it can see their resource usage.
  • Install the Metrics Server to expose pod CPU and memory metrics via the metrics.k8s.io API.
  • Configure a Horizontal Pod Autoscaler (HPA) to maintain a target utilization (e.g., aim for 80% CPU across Elasticsearch pods, with min/max replica counts).
A dark-themed dashboard panel titled "The Load Comes and Goes" showing a 24-hour line graph with a midday peak and time labels from 00:00 to 24:00, plus a small avatar labeled "Bob" on the right. Below the chart are two glowing blue cartoon characters standing on a platform.
A dark-themed infographic titled "The Horizontal Pod Autoscaler" showing a circular 80% CPU usage gauge labeled metrics-server and a rule badge reading "1–3 pods." Two stylized pod characters (orange and purple) sit on platform blocks with empty pod slots between them.
When load drops the HPA removes extra pods, but Kubernetes waits for a stabilization window so short dips don’t cause flapping.
An infographic titled "The Horizontal Pod Autoscaler" showing cartoon pod icons on server platforms. It highlights a scaling rule of "1–3 pods" and a metrics-server CPU gauge at 50%.
Pick HPA targets and stabilization windows carefully—poor choices can cause frequent scale events.
Install Metrics Server and start with conservative HPA thresholds. Monitor behavior and adjust min/max pod counts, target CPU, and stabilization settings to avoid oscillation. See the Kubernetes HPA docs for more details: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/.

Quick comparison and guidance

CLI sequence — apply these changes

Adjust names, namespaces, and endpoints to match your cluster. These commands illustrate the typical order: install Metrics Server, update Elasticsearch resources, deploy extra Fluentd collectors, create a sharded index and reindex data, then add an HPA.

Summary: patterns to apply

  • Tune resource requests and limits for steady load (vertical scaling).
  • Add targeted Fluentd collectors on busy nodes to spread ingestion (horizontal for collectors).
  • Reshard Elasticsearch indexes by creating new indexes and reindexing data when you need parallelism (horizontal for data).
  • Use Metrics Server + HPA to automate scaling for predictable load cycles.
This article outlines the concepts and typical commands. It does not provide complete manifests, cluster-safe reindex strategies, or Elasticsearch shard allocation tuning. For production clusters, plan reindex windows, snapshot before index changes, and follow the Elasticsearch and Kubernetes operator best practices:

Watch Video