Rook-Ceph을 포기한다. Host-Path가 있으니까 괜찮아!

쿠버네티스에서 Rook-Ceph 대신 HostPath를 선택한 이유 🤔

2025.04.08 개발 일지: Rook-Ceph과의 하루 종일 씨름 그리고 깨달음

안녕하세요! 오늘은 쿠버네티스 환경에서 저장소 시스템으로 Rook-Ceph를 구축하려다 HostPath로 전환한 여정을 공유하려고 합니다. 개발 환경에서 흔히 겪을 수 있는 문제와 해결 과정을 기록해 두면 누군가에게 도움이 될 수 있을 것 같아요. 😊

🔍 문제 상황: Rook-Ceph 클러스터가 제대로 동작하지 않는 현상

제 물뮤(MoolMeow) 프로젝트에서 Jenkins, Harbor 등의 CI/CD 도구들이 모두 Pending 상태에 머물러 있었어요. 원인을 파악해보니 Rook-Ceph 클러스터에 문제가 있었습니다.

현재 인프라 환경

저는 Mac Mini M2 Pro에서 VirtualBox를 통해 쿠버네티스 클러스터를 운영하고 있습니다:

마스터 노드:

  • RAM: 8GB
  • CPU: 4코어
  • 디스크: 80GB

워커 노드:

  • RAM: 4GB
  • CPU: 2코어
  • 디스크: 40GB
# 문제 확인
kubectl -n rook-ceph get cephclusters
kubectl -n rook-ceph get pods | grep osd

🧐 원인 분석

1. OSD(Object Storage Daemon) 부재

Ceph 클러스터는 생성되었지만 OSD가 없는 상태였습니다.

Reduced data availability: 128 pgs inactive
4 pool(s) have no replicas configured
usage: 0 B used, 0 B / 0 B avail

실제로 Ceph가 사용할 수 있는 저장소가 없었던 것이죠! 💾

2. 루프 디바이스 시도

문제 해결을 위해 루프 디바이스를 생성해 시도했습니다:

mkdir -p /var/lib/rook/osd-loop
truncate -s 10G /var/lib/rook/osd-loop/osd.img
losetup -fP /var/lib/rook/osd-loop/osd.img
losetup -a  # 연결 확인

하지만 이렇게 만든 디바이스를 Rook-Ceph가 인식하지 못했어요:

skipping OSD configuration as no devices matched the storage settings for this node "k8s-master"

3. 디스크 압박(Disk Pressure) 이슈

로그를 더 살펴보니 노드에 disk-pressure 테인트가 있었습니다:

kubectl get node k8s-master -o yaml | grep -A5 "taints:"
# 결과:
taints:
- effect: NoSchedule
  key: node.kubernetes.io/disk-pressure
  timeAdded: "2025-04-08T10:16:01Z"

이는 쿠버네티스가 디스크 공간 부족을 감지하고 자동으로 추가한 테인트입니다. 😱

4. 리소스 부족

마지막으로 가장 치명적인 원인을 발견했습니다:

Resource           Requests      Limits
--------           --------      ------
cpu                3 (75%)       3800m (95%)
memory             3568Mi (46%)  6996Mi (90%)

가상 머신의 리소스가 거의 한계에 도달해있었어요! Rook-Ceph 같은 무거운 분산 스토리지를 구동하기에는 부족한 환경이었던 거죠. 🚫

🛠️ 해결책: HostPath로 전환

이런 상황에서는 Rook-Ceph보다 가벼운 스토리지 솔루션을 선택하는 것이 현명합니다. 개발 환경이라면 HostPath를 사용하는 것이 좋은 대안이 될 수 있어요.

HostPath의 장점:

  • 🚀 설정이 간단하고 빠름
  • 🪶 적은 리소스 사용
  • 🧩 쿠버네티스 기본 기능으로 별도 설치 불필요
  • 🔧 개발 환경에 적합

HostPath PV 예시:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /mnt/moolmeow-dev/jenkins
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pvc
  namespace: jenkins
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  volumeName: jenkins-pv

💻 Rook-Ceph 권장 사양

Rook-Ceph를 제대로 운영하기 위해서는 생각보다 높은 사양이 필요합니다:

프로덕션 환경 권장 사양

  • CPU: 노드당 최소 4-8코어 (OSD당 약 1코어)
  • 메모리: 노드당 최소 8-16GB (OSD당 약 2GB + MON/MGR용 추가 메모리)
  • 디스크:
    • 시스템용 SSD 최소 50GB
    • 데이터용 전용 디스크 필요
    • 메타데이터용 별도 SSD 권장
  • 노드 수: 고가용성을 위해 최소 3개 노드

개발 환경 최소 사양

  • CPU: 최소 2-4코어
  • 메모리: 최소 4-8GB
  • 디스크: 최소 20-40GB 여유 공간

제 현재 환경(마스터 8GB/4코어, 워커 4GB/2코어)은 겉보기엔 최소 사양을 충족하는 것 같지만, 실제로는 쿠버네티스 자체와 다른 워크로드가 이미 상당한 리소스를 사용하고 있어 Rook-Ceph를 안정적으로 운영하기에는 부족했습니다.

🌟 결론

개발 환경에서는 리소스 상황을 고려하여 적절한 저장소 솔루션을 선택하는 것이 중요합니다. Rook-Ceph는 훌륭한 분산 스토리지 솔루션이지만, 충분한 리소스가 확보되지 않은 상태에서는 HostPath와 같은 가벼운 대안을 사용하는 것이 더 효율적일 수 있습니다.

이번 경험을 통해 쿠버네티스 환경에서의 저장소 선택과 리소스 관리의 중요성을 다시 한번 깨달았습니다. 여러분도 개발 환경 구성 시 참고하시길 바랍니다! 💪


📚 참고 명령어

# Ceph 상태 확인
kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- ceph status

# OSD 준비 및 생성 상태 확인 
kubectl -n rook-ceph get pods | grep osd

# 로그 확인
kubectl -n rook-ceph logs deploy/rook-ceph-operator | grep "osd"

# 디스크 사용량 확인
df -h

# 컨테이너 이미지 정리
docker system prune -a
# 또는 containerd 사용 시:
ctr image rm $(ctr image ls -q)

# 테인트 제거
kubectl taint nodes <노드이름> node.kubernetes.io/disk-pressure:NoSchedule-

Why I Chose HostPath Over Rook-Ceph in Kubernetes 🤔

April 8, 2025 Dev Journal: A Full Day Wrestling with Rook-Ceph and What I Learned

Hello there! Today I want to share my journey of attempting to set up Rook-Ceph as a storage system in a Kubernetes environment, and why I eventually switched to HostPath. I hope documenting these common development environment issues and their solutions might help someone else out there! 😊

🔍 The Problem: Rook-Ceph Cluster Not Working Properly

In my MoolMeow project, all CI/CD tools like Jenkins and Harbor were stuck in a Pending state. When I investigated, I found that the issue was with the Rook-Ceph cluster.

Current Infrastructure Environment

I’m running my Kubernetes cluster on VirtualBox VMs hosted on a Mac Mini M2 Pro:

Master Node:

  • RAM: 8GB
  • CPU: 4 cores
  • Disk: 80GB

Worker Node:

  • RAM: 4GB
  • CPU: 2 cores
  • Disk: 40GB
# Checking the problem
kubectl -n rook-ceph get cephclusters
kubectl -n rook-ceph get pods | grep osd

🧐 Root Cause Analysis

1. Missing OSDs (Object Storage Daemons)

The Ceph cluster was created, but there were no OSDs:

Reduced data availability: 128 pgs inactive
4 pool(s) have no replicas configured
usage: 0 B used, 0 B / 0 B avail

Essentially, Ceph had no actual storage to use! 💾

2. Loop Device Attempts

I tried creating loop devices to solve the problem:

mkdir -p /var/lib/rook/osd-loop
truncate -s 10G /var/lib/rook/osd-loop/osd.img
losetup -fP /var/lib/rook/osd-loop/osd.img
losetup -a  # Verify connection

However, Rook-Ceph couldn’t recognize these devices:

skipping OSD configuration as no devices matched the storage settings for this node "k8s-master"

3. Disk Pressure Issues

Further log inspection revealed a disk-pressure taint on the node:

kubectl get node k8s-master -o yaml | grep -A5 "taints:"
# Result:
taints:
- effect: NoSchedule
  key: node.kubernetes.io/disk-pressure
  timeAdded: "2025-04-08T10:16:01Z"

This is a taint that Kubernetes automatically adds when it detects low disk space. 😱

4. Resource Constraints

Finally, I discovered the most critical issue:

Resource           Requests      Limits
--------           --------      ------
cpu                3 (75%)       3800m (95%)
memory             3568Mi (46%)  6996Mi (90%)

The virtual machine was nearly at its resource limit! Not enough to run a heavy distributed storage system like Rook-Ceph. 🚫

🛠️ Solution: Switch to HostPath

In situations like this, it’s wise to choose a lighter storage solution than Rook-Ceph. For development environments, HostPath can be a good alternative.

Benefits of HostPath:

  • 🚀 Simple and quick to set up
  • 🪶 Uses minimal resources
  • 🧩 Built into Kubernetes, no additional installation required
  • 🔧 Suitable for development environments

Example HostPath PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /mnt/moolmeow-dev/jenkins
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pvc
  namespace: jenkins
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  volumeName: jenkins-pv

💻 Rook-Ceph Recommended Specifications

Running Rook-Ceph properly requires more substantial resources than you might expect:

Production Environment Recommendations

  • CPU: Minimum 4-8 cores per node (about 1 core per OSD)
  • Memory: Minimum 8-16GB per node (about 2GB per OSD + additional for MON/MGR)
  • Disk:
    • Minimum 50GB SSD for system
    • Dedicated disks for data
    • Separate SSD for metadata recommended
  • Node count: Minimum 3 nodes for high availability

Development Environment Minimum Requirements

  • CPU: Minimum 2-4 cores
  • Memory: Minimum 4-8GB
  • Disk: Minimum 20-40GB free space

My current setup (Master: 8GB RAM/4 cores, Worker: 4GB RAM/2 cores) seems to meet the minimum requirements on paper, but in reality, Kubernetes itself and other workloads were already consuming significant resources, making it insufficient for stable Rook-Ceph operation.

🌟 Conclusion

In development environments, it’s important to choose the appropriate storage solution based on your resource constraints. While Rook-Ceph is an excellent distributed storage solution, using lighter alternatives like HostPath can be more efficient when sufficient resources aren’t available.

This experience reminded me of the importance of storage selection and resource management in Kubernetes environments. I hope you find this helpful when setting up your own development environment! 💪


📚 Reference Commands

# Check Ceph status
kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- ceph status

# Check OSD preparation and creation status
kubectl -n rook-ceph get pods | grep osd

# Check logs
kubectl -n rook-ceph logs deploy/rook-ceph-operator | grep "osd"

# Check disk usage
df -h

# Clean up container images
docker system prune -a
# Or for containerd:
ctr image rm $(ctr image ls -q)

# Remove taint
kubectl taint nodes <node-name> node.kubernetes.io/disk-pressure:NoSchedule-

답글 남기기