-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (81 loc) · 3.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
ROOK_VERSION := 1.15.2
CEPH_VERSION := 18.2.4
MINIKUBE_VERSION := 1.34.0
YQ_VERSION := 4.44.3
HELM_VERSION := 3.16.1
BIN_DIR := bin
MINIKUBE := $(BIN_DIR)/minikube_$(MINIKUBE_VERSION)
YQ := $(BIN_DIR)/yq_$(YQ_VERSION)
HELM := $(BIN_DIR)/helm_$(HELM_VERSION)
OSD_COUNT := 1
OBJECT_STORE_CONSUMER_NS := default
# "raw" or "pvc"
DEVICE_MODE ?= pvc
# "docker" or "kvm"
DRIVER := docker
MANIFEST_DIR := manifest
$(BIN_DIR):
mkdir $(BIN_DIR)
$(MINIKUBE): | $(BIN_DIR)
curl -LO https://storage.googleapis.com/minikube/releases/v$(MINIKUBE_VERSION)/minikube-linux-amd64
mv minikube-linux-amd64 $(MINIKUBE)
chmod +x $(MINIKUBE)
$(YQ): | $(BIN_DIR)
curl -LO https://github.com/mikefarah/yq/releases/download/v$(YQ_VERSION)/yq_linux_amd64
mv yq_linux_amd64 $(YQ)
chmod +x $(YQ)
$(HELM): | $(BIN_DIR)
curl -L https://get.helm.sh/helm-v$(HELM_VERSION)-linux-amd64.tar.gz | tar xzv
mv linux-amd64/helm $(HELM)
rm -rf linux-amd64
chmod +x $(HELM)
generate: $(MANIFEST_DIR)/overrided_operator_values.yaml $(MANIFEST_DIR)/overrided_pvc_cluster_values.yaml $(MANIFEST_DIR)/overrided_raw_cluster_values.yaml
.PHONY: $(MANIFEST_DIR)/overrided_operator_values.yaml
$(MANIFEST_DIR)/overrided_operator_values.yaml: $(MANIFEST_DIR)/operator_values.yaml $(YQ)
$(YQ) '.image.tag = "v$(ROOK_VERSION)"' $< > $@
.PHONY: $(MANIFEST_DIR)/overrided_pvc_cluster_values.yaml
$(MANIFEST_DIR)/overrided_pvc_cluster_values.yaml: $(MANIFEST_DIR)/pvc_cluster_values.yaml $(YQ)
$(YQ) '.cephClusterSpec.cephVersion.image = "quay.io/ceph/ceph:v$(CEPH_VERSION)"' $< | \
$(YQ) '.cephClusterSpec.storage.storageClassDeviceSets[0].count = $(OSD_COUNT)' > $@
.PHONY: $(MANIFEST_DIR)/overrided_raw_cluster_values.yaml
$(MANIFEST_DIR)/overrided_raw_cluster_values.yaml: $(MANIFEST_DIR)/raw_cluster_values.yaml $(YQ)
$(YQ) '.cephClusterSpec.cephVersion.image = "quay.io/ceph/ceph:v$(CEPH_VERSION)"' $< > $@
for i in $$(seq 0 $$(expr $(OSD_COUNT) - 1)); do \
$(YQ) -i ".cephClusterSpec.storage.nodes[0].devices[$${i}].name = \"loop$${i}\"" $@; \
done
.PHONY: create-cluster
create-cluster: $(MINIKUBE)
$(MINIKUBE) start --driver=$(DRIVER) --cpus=2 --memory 6g --disk-size 10gb
for i in $$(seq 0 $$(expr $(OSD_COUNT) - 1)); do \
$(MINIKUBE) ssh -- dd if=/dev/zero of=loop$${i} bs=1 count=0 seek=6G; \
$(MINIKUBE) ssh -- sudo losetup /dev/loop$${i} loop$${i}; \
done
$(MINIKUBE) ssh -- lsblk
$(MINIKUBE) ssh -- docker pull rook/ceph:v$(ROOK_VERSION)
$(MINIKUBE) ssh -- docker pull quay.io/ceph/ceph:v$(CEPH_VERSION)
.PHONY: deploy
deploy: $(HELM) pv generate
$(HELM) repo add rook-release https://charts.rook.io/release
$(HELM) install --create-namespace --namespace rook-ceph rook-ceph rook-release/rook-ceph -f $(MANIFEST_DIR)/overrided_operator_values.yaml
$(HELM) repo add rook-release https://charts.rook.io/release
ifeq ($(DEVICE_MODE), pvc)
$(HELM) install --namespace rook-ceph rook-ceph-cluster rook-release/rook-ceph-cluster -f $(MANIFEST_DIR)/overrided_pvc_cluster_values.yaml
else ifeq ($(DEVICE_MODE), raw)
$(HELM) install --namespace rook-ceph rook-ceph-cluster rook-release/rook-ceph-cluster -f $(MANIFEST_DIR)/overrided_raw_cluster_values.yaml
endif
.PHONYE: pv
pv: $(MANIFEST_DIR)/pv-template.yaml $(MINIKUBE) $(YQ)
ifeq ($(DEVICE_MODE), pvc)
for i in $$(seq 0 $$(expr $(OSD_COUNT) - 1)); do \
$(YQ) ".metadata.name = \"pv$${i}\"" $< | \
$(YQ) ".spec.local.path = \"/dev/loop$${i}\"" | \
$(MINIKUBE) kubectl -- apply -f -; \
done
endif
.PHONY: clean
clean: $(MINIKUBE)
if [ $(DRIVER) = "docker" ]; then \
sudo losetup -D; \
fi
$(MINIKUBE) stop
$(MINIKUBE) delete