Kubernetes에서 OpenSearch Hot/Cold Storage와 Index Lifecycle 설계하기
Log를 OpenSearch에 넣는 일은 시작일 뿐이다. 수집량이 계속 늘면 어느 node에 쓰고, 언제 새 backing index로 넘기며, 언제 저비용 storage로 옮기고, 언제 삭제할지를 정해야 한다. 이 결정을 개별 Helm values나 ISM policy로 분리하면 capacity·복구·검색 성능의 trade-off가 보이지 않는다.
이 글은 Kubernetes 위 OpenSearch를 대상으로 StatefulSet Storage → data tier → Data Stream → rollover → retention을 한 lifecycle으로 설계한다. Trace event를 적재하는 방법은 Fluent Bit으로 Integration Trace Log Pipeline 만들기에서 다룬다. 이 글의 목적은 적재된 document를 어떤 물리적·Logical Boundary로 오래 운영할지 정하는 것이다.
Storage와 Index Lifecycle은 하나의 설계다
섹션 제목: “Storage와 Index Lifecycle은 하나의 설계다”Kubernetes storage는 Pod가 사라져도 data를 보존할 물리적 기반이고, index lifecycle은 document가 시간이 지남에 따라 어느 tier에 있을지 정하는 논리적 기반이다. 둘 중 하나만 설계하면 문제가 남는다. 빠른 local disk에만 Hot data를 두면 node 장애와 Pod 재배치가 recovery risk가 되고, durable storage만 사용하면 최근 write와 merge가 많은 tier의 latency와 비용이 커질 수 있다.
| 계층 | 주된 질문 | 일반적인 성질 |
|---|---|---|
| Cluster-manager | cluster state를 안전하게 보존하는가 | 작은 용량, 높은 durability |
| Ingest/client | request를 분산하고 변환하는가 | data persistence보다 network·CPU |
| Hot | 최근 write와 query를 감당하는가 | 높은 IOPS, 빠른 recovery |
| Cold | 드문 조회를 낮은 비용으로 보관하는가 | 큰 capacity, 느린 access 허용 |
각 tier의 replica, disk, node count는 RPO/RTO와 query SLA에서 나온다. hot과 cold라는 label만 붙인다고 data tier가 완성되지는 않는다. template, allocation, rollover, transition, PVC recovery가 같은 운영 모델로 연결되어야 한다.
Node Pool을 역할로 나눈다
섹션 제목: “Node Pool을 역할로 나눈다”앞의 tier 표는 논리적 역할이다. Kubernetes에서는 그 역할이 실제 node pool과 scheduling 경계로 내려와야 의미를 가진다. 하나의 worker pool에 application, batch job, log collector, OpenSearch data node를 함께 올리면 indexing burst가 application latency를 밀어내고, application의 CPU spike가 shard recovery를 지연시킨다. 두 문제 모두 ISM policy로는 해결되지 않는다.
이 배치가 지키는 경계는 네 가지다.
| 경계 | 분리하지 않으면 생기는 문제 |
|---|---|
| Application pool과 data pool | indexing I/O와 GC pause가 업무 request latency에 직접 반영된다 |
| Cluster-manager와 data node | data node의 heap pressure가 cluster state 관리와 master election을 흔든다 |
| Ingest/coordinating과 data node | 수집기의 bulk 부하와 dashboard의 search fan-out이 shard가 있는 node에 직접 쌓인다 |
| Hot pool과 Cold pool | 성능 요구와 보관 비용이 하나의 disk 예산으로 묶여 둘 다 최적화하지 못한다 |
수집기의 연결 지점도 이 경계에서 결정된다. Fluent Bit이 Hot data node의 endpoint를 직접 가리키면 수집 부하가 shard를 가진 node에 그대로 얹히고, node가 교체될 때 수집 설정도 함께 바뀐다. Ingest 또는 coordinating 계층의 Service로 보내면 ingestion pressure를 data tier와 분리하고, data node 구성 변경을 수집기에서 숨길 수 있다. Dashboards도 같은 이유로 data node를 직접 조회하지 않는다.
Dedicated cluster-manager는 최소 3 replica를 서로 다른 fault domain에 두어 quorum을 유지한다. 2 replica는 한 대만 잃어도 과반을 만들 수 없어 cluster state 갱신이 멈춘다. replica를 3으로 선언하는 것만으로는 부족하고, anti-affinity와 topology spread로 실제 배치가 분산되는지 확인해야 한다. 같은 node 또는 같은 hypervisor host에 3개가 몰리면 선언된 quorum은 장부상의 숫자일 뿐이다.
node pool을 나눴다면 그 경계를 scheduling으로 강제한다. label과 taint 없이 pool을 나누면 scheduler는 그것을 그냥 여유 있는 node로 본다.
nodeSelector: workload: opensearch-hottolerations: - key: dedicated operator: Equal value: opensearch-hot effect: NoScheduletopologySpreadConstraints: - maxSkew: 1 topologyKey: kubernetes.io/hostname whenUnsatisfiable: DoNotSchedule labelSelector: matchLabels: app.kubernetes.io/component: hot-dataHot과 Cold의 CPU·memory를 굳이 다르게 잡지 않는 구성도 흔하다. 두 tier의 차이는 대체로 core 수가 아니라 storage class와 용량에서 나오기 때문이다. 다만 그 경우에도 Cold pool을 별도 pool로 유지할 가치는 남는다. relocation이 진행되는 동안 Cold node의 disk와 network가 포화되어도 Hot pool의 indexing 경로는 영향을 받지 않는다.
StatefulSet과 Storage 경계를 정한다
섹션 제목: “StatefulSet과 Storage 경계를 정한다”StatefulSet의 volumeClaimTemplates는 Pod 이름마다 독립 PVC를 만든다. node가 바뀌어도 backend가 volume을 다시 attach할 수 있는 block·file storage라면 node-local disk보다 복구가 단순하다.
persistence: enabled: true storageClass: fast-rwo accessModes: - ReadWriteOnce size: 200Gi이 설정만으로 capacity planning이 끝나지는 않는다. PVC size는 primary shard, replica, segment merge의 일시적 증폭, snapshot restore 여유를 포함해야 한다. disk watermark를 넘기면 allocation이 멈추거나 shard relocation이 연쇄적으로 실패할 수 있으므로, usable capacity를 PVC nominal size와 같게 보지 않는다.
local disk 또는 hostPath는 Hot tier의 write 성능을 높일 수 있지만 명확한 비용을 가진다.
- Pod identity와 node affinity가 맞지 않으면 data path를 잃거나 다른 node의 빈 path로 시작할 수 있다.
- Pod별 directory를 분리하지 않으면 같은 node에 재배치된 Pod가 data를 충돌시킬 수 있다.
- ownership 보정용 privileged init container는 편하지만 host filesystem Authorization Boundary를 넓힌다.
- node drain, disk replacement, autoscaling은 volume detach/attach보다 복잡한 recovery runbook을 요구한다.
그러므로 local disk는 “더 빠른 PVC”가 아니다. node 실패 시 replica가 다른 fault domain에서 primary가 될 수 있는지, replacement node에 빈 data directory로 join해도 되는지, snapshot에서 복구할 때 운영자가 어떤 순서로 조치할지를 먼저 정한다. production data tier에 무분별한 hostPath를 쓰기보다 local persistent volume, topology-aware scheduling, snapshot policy를 함께 검토한다.
Data Stream과 Template으로 새 index를 통제한다
섹션 제목: “Data Stream과 Template으로 새 index를 통제한다”시간 흐름 event는 alias를 수동으로 바꾸기보다 Data Stream으로 관리하면 write target과 backing index 생성 규칙을 분리할 수 있다. Template은 새 backing index가 생길 때마다 mapping, setting, allocation requirement를 일관되게 적용한다.
{ "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 수는 node 수의 복사본이 아니다. 너무 많은 작은 shard는 cluster state, heap, search fan-out 비용을 키우고, 너무 큰 shard는 recovery와 relocation을 길게 만든다. 먼저 일일 ingest volume, retention, primary size 목표, query concurrency를 기준으로 shard size 범위를 정하고 benchmark로 보정한다. 3 primary / 1 replica 같은 숫자는 예시일 뿐 cluster마다 정답이 아니다.
Template은 첫 document보다 먼저 배포한다. 수집기가 먼저 write하면 dynamic mapping과 자동 생성 index가 원래 template을 우회할 수 있다. 이미 잘못 생성된 backing index에 template을 나중에 적용해도 mapping과 setting이 소급되지 않는다. 이 경우에는 영향 범위를 확인하고 rollover 또는 controlled reindex로 새 template을 적용한다. 운영 index를 무조건 삭제해서 해결하면 trace와 forensic evidence까지 잃을 수 있다.
ISM으로 rollover와 retention을 연결한다
섹션 제목: “ISM으로 rollover와 retention을 연결한다”Index State Management(ISM)는 backing index를 상태와 transition으로 관리한다. rollover는 새 write index를 만들고, retention transition은 이미 rollover된 오래된 index에 적용하는 식으로 책임을 나눈다.
{ "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": [] } ] }}age와 primary shard size를 함께 쓰면 시간 기반 운영 예측과 burst traffic 보호를 동시에 얻는다. 단, transition clock은 document의 event time이 아니라 backing index 생성 또는 rollover 기준이다. 늦게 도착한 event가 오래된 업무 시간을 가진다고 해서 자동으로 이전 cold index에 들어가지 않는다. late arrival 허용 범위, reindex 필요성, dashboard query time range는 별도로 정해야 한다.
Cold transition에는 relocation 시간이 든다. wait_for: true 같은 동작은 data copy가 완료될 때까지 다음 단계로 진행하지 않지만, cold tier가 부족하거나 allocation filter가 맞지 않으면 policy가 멈춘다. 따라서 ISM failure count, unassigned shard, hot disk watermark, rollover age를 함께 Alert 대상으로 둔다. lifecycle은 storage 비용 절감 기능이면서 동시에 data availability의 control plane이다.
Capacity와 복구 기준을 운영 신호로 만든다
섹션 제목: “Capacity와 복구 기준을 운영 신호로 만든다”운영자는 data stream 이름만 보고 문제가 없는지 판단할 수 없다. 아래 신호를 같은 dashboard 또는 runbook에서 보아야 한다.
| 신호 | 확인할 문제 | 초기 조치 |
|---|---|---|
| Hot disk watermark | rollover/merge/relocation 여유 부족 | ingest 증가, shard skew, allocation 확인 |
| Unassigned primary shard | write/read availability 저하 | allocation explanation과 node 상태 확인 |
| ISM action failure | retention 또는 rollover 중단 | policy state, permission, tier capacity 확인 |
| Backing index age/size | rollover 조건 불일치 | write target과 policy attachment 확인 |
| Snapshot freshness | tier 또는 node 상실 시 복구 불가 | repository와 restore drill 확인 |
삭제 policy는 backup policy가 아니다. 90일 retention은 90일 뒤 document를 지우겠다는 뜻일 뿐, snapshot이 유효하거나 restore가 가능한지 증명하지 않는다. snapshot retention, repository 접근 권한, restore 시간, index name conflict 처리를 정기적으로 drill해야 한다.
검증 순서
섹션 제목: “검증 순서”- 가상 data stream에 template과 ISM policy를 먼저 적용하고 policy explain 결과를 확인한다.
- 작은 test document를 적재해 mapping, write target, backing index setting이 예상과 일치하는지 확인한다.
- Hot, Cold, cluster-manager Pod가 의도한 node pool과 fault domain에 실제로 흩어졌는지 확인한다. 선언한 replica 수가 아니라 배치 결과를 본다.
- 짧은 age 또는 size threshold를 가진 비운영 policy로 rollover와 cold allocation을 재현한다.
- cold tier capacity 부족과 allocation mismatch를 의도적으로 만들고 policy failure와 Alert가 보이는지 확인한다.
- snapshot을 별도 이름으로 restore해 document, mapping, alias 또는 data stream 동작을 확인한다.
Kubernetes에서 OpenSearch Storage를 설계할 때 node pool, PVC, local disk, Data Stream, ISM은 독립 설정이 아니다. Node pool 분리는 indexing 부하와 업무 latency, cluster state와 data 처리를 서로 밀어내지 않게 하고, Hot tier는 ingest와 recovery 속도를, Cold tier는 retention 비용을, Template은 새 backing index의 contract를, ISM은 시간이 흐르는 동안의 placement를 책임진다. 이 경계를 함께 운영해야 disk pressure와 lifecycle failure가 search 누락이나 데이터 손실로 번지기 전에 발견할 수 있다.
다음 글인 OpenSearch TLS와 Least-Privilege RBAC 구성하기에서는 이 data lifecycle을 다루는 node와 client가 어떤 identity와 TLS 경계로 연결되어야 하는지 설명한다.