Skip to content

Designing OpenSearch Hot/Cold Storage and Index Lifecycles on Kubernetes

Interactive Diagram

새 탭 ↗

Putting logs into OpenSearch is only the start. As ingestion grows, the system must decide which nodes receive writes, when to create a new backing index, when to move data to lower-cost storage, and when to delete it. When these decisions are isolated in Helm values or an ISM policy, the trade-offs between capacity, recovery, and search performance disappear.

This article designs StatefulSet storage → data tier → Data Stream → rollover → retention as one lifecycle for OpenSearch on Kubernetes. Building an Integration Trace Log Pipeline with Fluent Bit covers how Trace events are ingested. The concern here is the physical and logical boundary used to operate those documents over time.

Storage and index lifecycle are one design

Section titled “Storage and index lifecycle are one design”
PlantUML Diagram

Kubernetes storage is the physical basis that preserves data when a Pod disappears, while the index lifecycle is the logical basis that decides where a document lives as it ages. Designing only one leaves a gap. Keeping Hot data only on fast local disks can turn node failure and Pod rescheduling into recovery risk; using only durable remote storage can raise latency and cost for the tier with the most recent writes and merges.

TierPrimary questionTypical property
Cluster-managerIs cluster state preserved safely?Small capacity, high durability
Ingest/clientCan requests be distributed and transformed?Network and CPU more than persisted data
HotCan recent writes and queries be sustained?High IOPS, fast recovery
ColdCan infrequent queries be retained cheaply?Large capacity, slower access accepted

Each tier’s replica count, disk, and node count follows its RPO/RTO and query SLA. Adding hot and cold labels alone does not create a data tier. Template, allocation, rollover, transition, and PVC recovery must form one operating model.

The tier table above describes logical roles. In Kubernetes those roles only mean something once they map to real node pools and scheduling boundaries. Placing applications, batch jobs, log collectors, and OpenSearch data nodes on one worker pool lets an indexing burst push out application latency and lets an application CPU spike delay shard recovery. Neither problem is solvable by an ISM policy.

PlantUML Diagram

This layout preserves four boundaries.

BoundaryProblem when it is not separated
Application pool and data poolIndexing I/O and GC pauses appear directly in business request latency
Cluster-manager and data nodeHeap pressure on a data node destabilizes cluster-state management and master election
Ingest/coordinating and data nodeCollector bulk load and dashboard search fan-out land directly on nodes holding shards
Hot pool and Cold poolPerformance needs and retention cost share one disk budget, so neither is optimized

The collector’s connection point follows from the same boundary. If Fluent Bit points at a Hot data node endpoint, ingestion load lands on the node holding shards, and replacing that node also changes the collector configuration. Sending to an Ingest or coordinating Service separates ingestion pressure from the data tier and hides data-node topology from the collector. Dashboards avoid querying data nodes directly for the same reason.

A dedicated cluster-manager needs at least 3 replicas across distinct fault domains to hold quorum. With 2 replicas, losing one leaves no majority and cluster-state updates stop. Declaring 3 replicas is not sufficient by itself; verify actual placement with anti-affinity and topology spread. Three replicas packed onto one node or one hypervisor host make the declared quorum a number on paper.

Once pools are split, enforce the boundary through scheduling. Without labels and taints, the scheduler treats a separate pool as simply another node with free capacity.

nodeSelector:
workload: opensearch-hot
tolerations:
- key: dedicated
operator: Equal
value: opensearch-hot
effect: NoSchedule
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/component: hot-data

Giving Hot and Cold the same CPU and memory is a common choice, because the difference between the tiers usually comes from storage class and capacity rather than core count. Even then, keeping Cold as its own pool still pays off: while relocation saturates Cold-node disk and network, the Hot pool’s indexing path stays unaffected.

A StatefulSet volumeClaimTemplates creates an independent PVC for each Pod identity. With block or file storage that can reattach a volume after a node change, recovery is simpler than with node-local disk.

persistence:
enabled: true
storageClass: fast-rwo
accessModes:
- ReadWriteOnce
size: 200Gi

This alone is not capacity planning. PVC size must include primary shards, replicas, temporary amplification during segment merges, and snapshot-restore headroom. When disk watermarks are crossed, allocation can stop or shard relocation can fail in a chain, so usable capacity is not the nominal PVC size.

Local disk or hostPath can improve Hot-tier write performance, but it carries explicit costs.

  • If Pod identity and node affinity do not match, the process can lose its data path or start against an empty path on another node.
  • Without one directory per Pod, a rescheduled Pod on the same node can collide with existing data.
  • A privileged init container used for ownership correction broadens the host filesystem permission boundary.
  • Node drain, disk replacement, and autoscaling require a more complex recovery runbook than volume detach and attach.

Local disk is therefore not simply a faster PVC. First define whether a replica in another fault domain can become primary after node failure, whether a replacement node may join with an empty data directory, and which recovery sequence operators follow from a snapshot. Rather than applying hostPath broadly to production data tiers, evaluate local persistent volumes, topology-aware scheduling, and snapshot policy together.

Control new indexes with Data Streams and templates

Section titled “Control new indexes with Data Streams and templates”

For time-ordered events, a Data Stream avoids manually changing an alias by separating the write target from backing-index creation rules. A template applies mapping, settings, and allocation requirements consistently whenever a new backing index appears.

{
"index_patterns": ["logs-integration-*"],
"data_stream": {},
"priority": 200,
"template": {
"settings": {
"index.number_of_shards": 3,
"index.number_of_replicas": 1,
"index.routing.allocation.include._tier_preference": "data_hot"
},
"mappings": {
"dynamic": "strict",
"properties": {
"@timestamp": { "type": "date" },
"guid": { "type": "keyword" },
"interfaceId": { "type": "keyword" },
"eventType": { "type": "keyword" },
"message": { "type": "text" }
}
}
}
}

Shard count is not a copy of the node count. Too many small shards increase cluster-state, heap, and search fan-out cost; oversized shards lengthen recovery and relocation. Start from daily ingest volume, retention, target primary size, and query concurrency, then tune with benchmarks. A value such as 3 primary / 1 replica is only an example, not a universal answer.

Deploy the template before the first document. If the collector writes first, dynamic mapping and an automatically created index may bypass the intended template. Applying a template after a backing index was created does not retroactively change its mapping or settings. Inspect the blast radius, then use rollover or a controlled reindex to apply the new template. Deleting a production index indiscriminately also deletes Trace and forensic evidence.

Index State Management (ISM) manages a backing index through states and transitions. Rollover creates a new write index, while retention transitions act on older indexes that have already rolled over.

{
"policy": {
"description": "example integration trace lifecycle",
"default_state": "hot",
"ism_template": [
{ "index_patterns": ["logs-integration-*"], "priority": 200 }
],
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "1d",
"min_primary_shard_size": "30gb"
}
}
],
"transitions": [
{ "state_name": "cold", "conditions": { "min_rollover_age": "14d" } }
]
},
{
"name": "cold",
"actions": [
{
"allocation": {
"require": { "_tier": "data_cold" },
"wait_for": true
}
}
],
"transitions": [
{ "state_name": "delete", "conditions": { "min_rollover_age": "90d" } }
]
},
{
"name": "delete",
"actions": [{ "delete": {} }],
"transitions": []
}
]
}
}

Using both age and primary-shard size provides time-based operating predictability and burst-traffic protection. However, the transition clock follows backing-index creation or rollover, not the document’s business event time. A late event with an old business timestamp does not automatically enter an older Cold index. Late-arrival tolerance, reindexing needs, and dashboard query ranges must be designed separately.

A Cold transition takes relocation time. A setting such as wait_for: true prevents later progress until the copy finishes, but the policy stalls when Cold-tier capacity is insufficient or an allocation filter does not match. Alert on ISM failures, unassigned shards, Hot disk watermarks, and rollover age together. Lifecycle is a storage-cost feature and also the control plane for data availability.

Turn capacity and recovery into operational signals

Section titled “Turn capacity and recovery into operational signals”

An operator cannot infer health from a Data Stream name alone. Inspect these signals in the same dashboard or runbook.

SignalProblem to investigateFirst action
Hot disk watermarkInsufficient rollover, merge, or relocation headroomCheck ingest increase, shard skew, allocation
Unassigned primary shardReduced write/read availabilityCheck allocation explanation and node health
ISM action failureStopped retention or rolloverCheck policy state, permissions, tier capacity
Backing-index age/sizeRollover condition mismatchCheck write target and policy attachment
Snapshot freshnessUnrecoverable tier or node lossCheck repository and restore drill

A delete policy is not a backup policy. Ninety-day retention only says that documents are removed after ninety days; it does not prove that a snapshot is valid or restorable. Regularly drill snapshot retention, repository access, restore duration, and index-name conflict handling.

  1. Apply the template and ISM policy to a fictional Data Stream, then inspect policy explain output.
  2. Ingest a small test document and confirm mapping, write target, and backing-index settings.
  3. Confirm that Hot, Cold, and cluster-manager Pods actually spread across the intended node pools and fault domains. Inspect placement, not the declared replica count.
  4. Reproduce rollover and Cold allocation with non-production thresholds using short age or size values.
  5. Intentionally create insufficient Cold capacity and an allocation mismatch, then confirm policy failure and Alert visibility.
  6. Restore a snapshot under a separate name and verify documents, mapping, and alias or Data Stream behavior.

For OpenSearch on Kubernetes, node pools, PVCs, local disks, Data Streams, and ISM are not independent settings. Node-pool separation keeps indexing load and business latency, and cluster state and data handling, from pushing each other out. The Hot tier owns ingest and recovery speed, the Cold tier owns retention cost, the template owns the contract of new backing indexes, and ISM owns placement over time. Operating these boundaries together exposes disk pressure and lifecycle failure before they become missing search results or data loss.

The next article, Configuring OpenSearch TLS and Least-Privilege RBAC, explains the identity and TLS boundaries required for the nodes and clients that operate this data lifecycle.