Skip to content

Instantly share code, notes, and snippets.

@tafaust
Last active February 15, 2025 18:59
Show Gist options
  • Select an option

  • Save tafaust/05d68f268da8b94bca52b1c0d55bb1b5 to your computer and use it in GitHub Desktop.

Select an option

Save tafaust/05d68f268da8b94bca52b1c0d55bb1b5 to your computer and use it in GitHub Desktop.
Ceph Makefile
# --- 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