Last active
February 15, 2025 18:59
-
-
Save tafaust/05d68f268da8b94bca52b1c0d55bb1b5 to your computer and use it in GitHub Desktop.
Ceph Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # --- Configuration --- | |
| MON_IP ?= 192.168.1.10 # Primary monitor node IP | |
| POOL_NAME ?= $(shell sudo ceph osd pool ls | grep "cephfs.cephfs.data" || echo "default_pool") | |
| POOL_SIZE ?= 3 | |
| OSD_DEVICES ?= /dev/sdb # Modify as per your system | |
| FS_NAME ?= cephfs | |
| CEPH_IMAGE ?= quay.io/ceph/ceph:v17 | |
| # Cluster Nodes | |
| MON_NODES = mon1 mon2 mon3 | |
| OSD_NODES = osd1 osd2 osd3 | |
| MGR_NODES = mgr1 | |
| MDS_NODES = mds1 | |
| # SSH Credentials | |
| SSH_USER ?= ceph-admin | |
| # --- High-Level Targets --- | |
| .PHONY: setup-cluster expand-cluster recover-cluster monitor-cluster upgrade-cluster status clean glossary ceph-versions | |
| ## Full Cluster Setup (One Command) | |
| setup-cluster: install bootstrap add-mon add-osd add-mgr add-mds create-pool enable-dashboard status | |
| @echo "β Ceph Cluster Setup Completed!" | |
| ## Expand the Cluster with New Storage Nodes | |
| expand-cluster: add-osd | |
| @echo "β Ceph Cluster Expanded!" | |
| ## Detect and Recover Failed OSDs | |
| recover-cluster: | |
| @echo "π Checking for failed OSDs..." | |
| @FAILED_OSDS=$$(sudo ceph health detail | grep -oP 'osd.\d+' | grep -oP '\d+'); \ | |
| if [ -n "$$FAILED_OSDS" ]; then \ | |
| for osd in $$FAILED_OSDS; do \ | |
| echo "π Replacing OSD $$osd"; \ | |
| sudo ceph osd out $$osd; \ | |
| sudo ceph osd purge $$osd --yes-i-really-mean-it; \ | |
| sudo ceph orch apply osd --all-available-devices; \ | |
| done; \ | |
| echo "β OSD Recovery Completed!"; \ | |
| else \ | |
| echo "β No failed OSDs detected."; \ | |
| fi | |
| ## Enable Monitoring (Prometheus & Grafana) | |
| monitor-cluster: | |
| @echo "π Setting up monitoring..." | |
| sudo ceph mgr module enable prometheus | |
| sudo ceph mgr module enable dashboard | |
| sudo ceph dashboard create-self-signed-cert | |
| @echo "β Monitoring enabled! Access Grafana via the Ceph dashboard." | |
| ## Upgrade the Ceph Cluster | |
| upgrade-cluster: | |
| @echo "β¬οΈ Upgrading Ceph to $(CEPH_IMAGE)..." | |
| sudo ceph orch upgrade start --image $(CEPH_IMAGE) | |
| @echo "β Ceph upgrade initiated!" | |
| ## Check Cluster Status | |
| status: | |
| @echo "π Checking Ceph Cluster Status..." | |
| sudo ceph status | |
| ## Clean up (Reset Cluster) | |
| clean: | |
| @echo "ποΈ WARNING: This will remove all Ceph data!" | |
| sudo cephadm rm-cluster --force --zap-osds | |
| @echo "β Ceph Cluster Removed!" | |
| ## Display a Glossary of Ceph Terms | |
| glossary: | |
| @echo "π Ceph Glossary:" | |
| @echo "-----------------------------------" | |
| @echo "πΉ MON (Monitor) - Tracks cluster state and quorum." | |
| @echo "πΉ OSD (Object Storage Daemon) - Stores and replicates data." | |
| @echo "πΉ MGR (Manager) - Provides monitoring and management tools." | |
| @echo "πΉ MDS (Metadata Server) - Supports CephFS (file storage)." | |
| @echo "πΉ RBD (RADOS Block Device) - Ceph's block storage solution." | |
| @echo "πΉ RGW (RADOS Gateway) - S3-compatible object storage." | |
| @echo "πΉ Erasure Coding - Data redundancy alternative to replication." | |
| @echo "πΉ Placement Group (PG) - Logical grouping of OSDs for data distribution." | |
| @echo "πΉ Quorum - Minimum required MONs to maintain cluster integrity." | |
| @echo "πΉ BlueStore - Default storage backend for Ceph OSDs." | |
| @echo "πΉ Ceph Dashboard - Web UI for monitoring and management." | |
| @echo "-----------------------------------" | |
| ## Display Ceph Versions and End-of-Life Status | |
| ceph-versions: | |
| @echo "π Fetching Ceph Versions and EOL Status..." | |
| @echo "-----------------------------------" | |
| @echo "Active Releases:" | |
| @echo "-----------------------------------" | |
| @echo "Name | Initial Release | Latest | EOL (Estimated)" | |
| @echo "---------|-----------------|---------|-----------------" | |
| @echo "Squid | 2024-09-26 | 19.2.1 | 2026-09-19" | |
| @echo "Reef | 2023-08-07 | 18.2.4 | 2025-08-01" | |
| @echo "" | |
| @echo "-----------------------------------" | |
| @echo "Archived Releases:" | |
| @echo "-----------------------------------" | |
| @echo "Name | Initial Release | Latest | EOL" | |
| @echo "---------|-----------------|---------|-----------------" | |
| @echo "Quincy | 2022-04-19 | 17.2.8 | 2025-01-13" | |
| @echo "Pacific | 2021-03-31 | 16.2.15 | 2024-03-04" | |
| @echo "Octopus | 2020-03-23 | 15.2.17 | 2022-08-09" | |
| @echo "Nautilus | 2019-03-19 | 14.2.22 | 2021-06-30" | |
| @echo "Mimic | 2018-06-01 | 13.2.10 | 2020-07-22" | |
| @echo "Luminous | 2017-08-01 | 12.2.13 | 2020-03-01" | |
| @echo "-----------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment