-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Makefile
executable file
·139 lines (124 loc) · 5.57 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include ../image.mk
# ====================================================================================
# Image Build Options
ifeq ($(GOARCH),amd64)
CEPH_VERSION = v16.2.6-20210918
else
CEPH_VERSION = v16.2.6-20210918
endif
REGISTRY_NAME = quay.io
BASEIMAGE = $(REGISTRY_NAME)/ceph/ceph-$(GOARCH):$(CEPH_VERSION)
CEPH_IMAGE = $(BUILD_REGISTRY)/ceph-$(GOARCH)
OPERATOR_SDK_VERSION = v0.17.1
# TODO: update to yq v4 - v3 end of life in Aug 2021 ; v4 removes the 'yq delete' cmd and changes syntax
YQ_VERSION = 3.3.0
GOHOST := GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go
MANIFESTS_DIR=../../cluster/examples/kubernetes/ceph
TEMP := $(shell mktemp -d)
ifeq ($(HOST_PLATFORM),linux_amd64)
OPERATOR_SDK_PLATFORM = x86_64-linux-gnu
INCLUDE_CSV_TEMPLATES = true
endif
ifeq ($(HOST_PLATFORM),darwin_amd64)
OPERATOR_SDK_PLATFORM = x86_64-apple-darwin
INCLUDE_CSV_TEMPLATES = true
endif
ifneq ($(INCLUDE_CSV_TEMPLATES),true)
$(info )
$(info NOT INCLUDING OLM/CSV TEMPLATES!)
$(info )
endif
OPERATOR_SDK := $(TOOLS_HOST_DIR)/operator-sdk-$(OPERATOR_SDK_VERSION)
YQ := $(TOOLS_HOST_DIR)/yq-$(YQ_VERSION)
export OPERATOR_SDK YQ
# ====================================================================================
# Build Rook
do.build:
@echo === container build $(CEPH_IMAGE)
@cp Dockerfile $(TEMP)
@cp toolbox.sh $(TEMP)
@cp set-ceph-debug-level $(TEMP)
@cp $(OUTPUT_DIR)/bin/linux_$(GOARCH)/rook $(TEMP)
@cp $(OUTPUT_DIR)/bin/linux_$(GOARCH)/rookflex $(TEMP)
@cp -r $(MANIFESTS_DIR)/csi/template $(TEMP)/ceph-csi
@cp -r $(MANIFESTS_DIR)/monitoring $(TEMP)/ceph-monitoring
@mkdir -p $(TEMP)/rook-external/test-data
@cp $(MANIFESTS_DIR)/create-external-cluster-resources.* $(TEMP)/rook-external/
@cp $(MANIFESTS_DIR)/test-data/ceph-status-out $(TEMP)/rook-external/test-data/
@$(MAKE) list-image
ifeq ($(INCLUDE_CSV_TEMPLATES),true)
@$(MAKE) CSV_TEMPLATE_DIR=$(TEMP) generate-csv-templates
@cp -r $(TEMP)/cluster/olm/ceph/templates $(TEMP)/ceph-csv-templates
else
mkdir $(TEMP)/ceph-csv-templates
endif
@cd $(TEMP) && $(SED_IN_PLACE) 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
@if [ -z "$(BUILD_CONTAINER_IMAGE)" ]; then\
$(DOCKERCMD) build $(BUILD_ARGS) \
--build-arg ARCH=$(GOARCH) \
--build-arg TINI_VERSION=$(TINI_VERSION) \
-t $(CEPH_IMAGE) \
$(TEMP);\
fi
@rm -fr $(TEMP)
# generate CSV template files into the directory defined by the env var CSV_TEMPLATE_DIR
# CSV_TEMPLATE_DIR will be created if it doesn't already exist
generate-csv-templates: $(OPERATOR_SDK) $(YQ) ## Generate CSV templates for OLM into CSV_TEMPLATE_DIR
@if [[ -z "$(CSV_TEMPLATE_DIR)" ]]; then echo "CSV_TEMPLATE_DIR is not set"; exit 1; fi
@# first, copy the existing CRDs and OLM catalog directory to CSV_TEMPLATE_DIR
@# then, generate or copy all prerequisites into CSV_TEMPLATE_DIR (e.g., CRDs)
@# finally, generate the templates in-place using CSV_TEMPLATE_DIR as a staging dir
@mkdir -p $(CSV_TEMPLATE_DIR)
@cp -a ../../cluster $(CSV_TEMPLATE_DIR)/cluster
@set -eE;\
BEFORE_GEN_CRD_SIZE=$$(wc -l < $(MANIFESTS_DIR)/crds.yaml);\
$(MAKE) -C ../.. NO_OB_OBC_VOL_GEN=true MAX_DESC_LEN=0 BUILD_CRDS_INTO_DIR=$(CSV_TEMPLATE_DIR) crds;\
AFTER_GEN_CRD_SIZE=$$(wc -l < $(CSV_TEMPLATE_DIR)/cluster/examples/kubernetes/ceph/crds.yaml);\
if [ "$$BEFORE_GEN_CRD_SIZE" -le "$$AFTER_GEN_CRD_SIZE" ]; then\
echo "the new crd file must be smaller since the description fields were stripped!";\
echo "length before $$BEFORE_GEN_CRD_SIZE";\
echo "length after $$AFTER_GEN_CRD_SIZE";\
exit 1;\
fi
@OLM_CATALOG_DIR=$(CSV_TEMPLATE_DIR)/cluster/olm/ceph ../../cluster/olm/ceph/generate-rook-csv-templates.sh
@echo " === Generated CSV templates can be found at $(CSV_TEMPLATE_DIR)/cluster/olm/ceph/templates"
$(YQ):
@echo === installing yq $(GOHOST)
@mkdir -p $(TOOLS_HOST_DIR)
@curl -JL https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$(HOST_PLATFORM) -o $(YQ)
@chmod +x $(YQ)
$(OPERATOR_SDK):
@echo === installing operator-sdk $(GOHOST)
@mkdir -p $(TOOLS_HOST_DIR)
@curl -JL -o $(TOOLS_HOST_DIR)/operator-sdk-$(OPERATOR_SDK_VERSION) \
https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk-$(OPERATOR_SDK_VERSION)-$(OPERATOR_SDK_PLATFORM)
@chmod +x $(OPERATOR_SDK)
csv: $(OPERATOR_SDK) $(YQ) ## Generate a CSV file for OLM.
@echo Generating CSV manifests
@cd ../.. && cluster/olm/ceph/generate-rook-csv.sh $(CSV_VERSION) $(CSV_PLATFORM) $(ROOK_OP_VERSION)
csv-clean: $(OPERATOR_SDK) $(YQ) ## Remove existing OLM files.
@rm -fr ../../cluster/olm/ceph/deploy/* ../../cluster/olm/ceph/templates/*
# list-image creates list of images for offline installation
list-image:
@echo "producing list of images for offline installation";\
# remove the file if already exists
rm -f $(MANIFESTS_DIR)/images.txt;\
awk '/image:/ {print $2}' $(MANIFESTS_DIR)/operator.yaml $(MANIFESTS_DIR)/cluster.yaml | \
cut -d: -f2- |\
tee -a $(MANIFESTS_DIR)/images.txt && \
awk '/quay.io/ || /k8s.gcr.io/ {print $3}' ../../pkg/operator/ceph/csi/spec.go | \
cut -d= -f2- |\
tr -d '"' | tee -a $(MANIFESTS_DIR)/images.txt