ceph
1 Rook Ceph
- 레퍼런스
- 일반적으로 스토리지 클래스를 통해 동적으로 퍼시스턴트 볼륨을 생성한다.
- 스토리지 인프라가 제공되는 퍼블릭 클라우드과 같은 환경이라면 연동을 위한 CSI 드라이버 설치 및 스토리지 클래스를 정의하면 끝이다.
- 이런 환경이 아니라면 스토리지 시스템을 직접 구성해야한다.
1.1 Ceph
- Ceph는 수년간 운영 환경을 구축한 블록 스토리지, 객체 스토리지 및 공유 파일 시스템을 위한 확장성이 뛰어난 분산 스토리지 솔루션이다.
- ceph architecture
1.2 Rook
- Rook은 쿠버네티스의 구성 요소를 사용해 쿠버네티스 상에서 ceph가 동작하게 해준다.
- ceph이 쿠버네티스 클러스터에 동작중이면 쿠버네티스의 애플리케이션은 rook에 의해 관리되는 블록 디바이스와 파일 시스템을 마운트할 수 있다.
- Rook operator가 스토리지 설정을 자동화해주며 스토리지의 사용 여부와 상태를 모니터링 한다.
2 Rook의 구조
- Ceph의 각 서비스 데몬들이 POD로 실행된다.
- 서비스 데몬이 사용자 어플리케이션과 같은 노드에서 실행된다.
- 별도의 전용 스토리지 노드로 구성하는 것도 가능하다.
- 더 자세한 구조가 궁금하면 여기
2.1 Operator
- Operator는 storage cluster를 부트스트랩하고 모니터링하는 컨테이너다.
- Operator는 MON을 시작하고 모니터링한다.
2.2 Ceph Manager
- The Ceph Manager daemon (ceph-mgr) runs alongside monitor daemons, to provide additional monitoring and interfaces to external monitoring and management systems.
- By default, the manager daemon requires no additional configuration, beyond ensuring it is running.
- If there is no mgr daemon running, you will see a health warning to that effect, and some of the other information in the output of ceph status will be missing or stale until a mgr is started.
- 고가용성을 위해 2개 이상의 인스턴스가 필요 하나는 활성화하고 하는 준비상태.
2.3 MDS
- The Ceph MetaData Server daemon. Also referred to as “ceph-mds”.
- The Ceph metadata server daemon must be running in any Ceph cluster that runs the CephFS file system.
- The MDS stores all filesystem metadata.
2.4 MON
- The Ceph monitor software.
- A daemon that maintains a map of the state of the cluster.
- This “cluster state” includes the monitor map, the manager map, the OSD map, and the CRUSH map.
- A Ceph cluster must contain a minimum of three running monitors in order to be both redundant and highly-available.
- Ceph monitors and the nodes on which they run are often referred to as “mon”s.
2.5 OSD
- Ceph Object Storage Daemon.
- OSD는 logical disks와 상호작 용하는 소프트웨어다.
- OSD pod의 수는 cluster 생성 시 설정한 노드와 디바이스 설정을 통해 지정한다.
2.6 RGW
- RADOS Gate Way.
- The component of Ceph that provides a gateway to both the Amazon S3 RESTful API and the OpenStack Swift API.
- Also called “RADOS Gateway” and “Ceph Object Gateway”
3 install
- v1.9 버전 기준
3.1 Prerequisites
- 몇가지 전제 조건만 만족하면 Rook은 임의의 쿠버네티스 클러스터에 설치할 수 있다.
- 레퍼런스
Kubernetes 버전
- Kubernetes의 버전이 v1.16 이상
Ceph Prerequisites
- Ceph storage cluster 설정을 위해 아래에서 최소 한개의 local storage 조건이 충족되어야 한다.
- Raw devices (no partitions or formatted filesystems)
- Raw partitions (no formatted filesystem)
- PVs available from a storage class in
block
mode
partitions 또는 devices의 formatted 여부 확인하기
$ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
vda
└─vda1 LVM2_member >eSO50t-GkUV-YKTH-WsGq-hNJY-eKNf-3i07IB
├─ubuntu--vg-root ext4 c2366f76-6e21-4f10-a8f3-6776212e2fe4 /
└─ubuntu--vg-swap_1 swap 9492a3dc-ad75-47cd-9596-678e8cf17ff9 [SWAP]
vdb
- FSTYPE가 비어있지 않으면 formatted된 것
- 위에서는
vda
은 이미 formatted되어 사용할 수 없고vdb
는 formatted되지 않아 사용할 수 있다.
LVM package
- Ceph OSD는 아래와 같은 상황에서 LVM에 대한 의존성을 가진다.
- OSDs are created on raw devices or partitions
- If encryption is enabled (
encryptedDevice: true
in the cluster CR) - A
metadata
device is specified
- Ceph OSD가 LVM에 의존성을 가지는 경우 OSD가 작동하는 호스트에 LVM이 설치되어 있어야한다.
- 노드가 재기동되면 해당 노드에서 작동하고 있는 OSD가 실패할 것 따라서 아래 명령어로 LVM을 설치하자.
LVM package 설치
## CentOS
sudo yum install -y lvm2
## Ubuntu
sudo apt-get install -y lvm2
3.2 Helm Charts
- Rook Ceph v1.9 기준
- Rook은 아래 두 가지 helm 차트를 제공한다.
- Rook Ceph Operator: Ceph CR(사용자 지정 리소스)을 모니터링할 Ceph Operator를 설치한다.
- Rook Ceph Cluster: Operator가 클러스터를 구성하는 데 사용할 Ceph CR을 생성한다.
Prerequisites
- Kubernetes 1.17+
- Helm 3.x
Installing Operator
- Operator의 설정 값은 아래 참조
- values.yaml
- Default values for rook-ceph-operator
helm repo add rook-release https://charts.rook.io/release
helm install --create-namespace --namespace rook-ceph rook-ceph rook-release/rook-ceph -f values.yaml
helm delete --namespace rook-ceph rook-ceph
Installing Cluster
- Cluster의 설정 값은 아래 참조
- https://github.com/rook/rook/blob/master/deploy/charts/rook-ceph-cluster/values.yaml
- https://rook.io/docs/rook/v1.10/CRDs/Cluster/ceph-cluster-crd/
helm repo add rook-release https://charts.rook.io/release
helm install --create-namespace --namespace rook-ceph rook-ceph-cluster \
--set operatorNamespace=rook-ceph rook-release/rook-ceph-cluster -f values-override.yaml
helm delete --namespace rook-ceph rook-ceph-cluster
4 Clean Up
4.1 Delete the Block and File artifacts
kubectl delete -f ../wordpress.yaml
kubectl delete -f ../mysql.yaml
kubectl delete -n rook-ceph cephblockpool replicapool
kubectl delete storageclass rook-ceph-block
kubectl delete -f csi/cephfs/kube-registry.yaml
kubectl delete storageclass csi-cephfs
4.2 Delete the CephCluster CRD
$ kubectl -n rook-ceph patch cephcluster rook-ceph --type merge -p '{"spec":{"cleanupPolicy":{"confirmation":"yes-really-destroy-data"}}}'
$ kubectl -n rook-ceph delete cephcluster rook-ceph
## 확인
$ kubectl -n rook-ceph get cephcluster
4.3 Delete the Operator and related Resources
kubectl delete -f operator.yaml
kubectl delete -f common.yaml
kubectl delete -f crds.yaml
4.4 Delete the data on hosts
- Connect to each machine and delete
/var/lib/rook
, or the path specified by thedataDirHostPath
.
$ sudo rm -rf /var/lib/rook
4.5 Zapping Devices
- Disks on nodes used by Rook for osds can be reset to a usable state with methods suggested below.
- Note that these scripts are not one-size-fits-all. Please use them with discretion to ensure you are not removing data unrelated to Rook and/or Ceph.
DISK="/dev/sdX"
## Zap the disk to a fresh, usable state (zap-all is important, b/c MBR has to be clean)
sgdisk --zap-all $DISK
## Wipe a large portion of the beginning of the disk to remove more LVM metadata that may be present
dd if=/dev/zero of="$DISK" bs=1M count=100 oflag=direct,dsync
## SSDs may be better cleaned with blkdiscard instead of dd
blkdiscard $DISK
## Inform the OS of partition table changes
partprobe $DISK