Makefile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # Copyright 2016 The Rook Authors. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. include ../image.mk
  15. # ====================================================================================
  16. # Image Build Options
  17. ifeq ($(GOARCH),amd64)
  18. CEPH_VERSION ?= v18.2.1-20231215
  19. else
  20. CEPH_VERSION ?= v18.2.1-20231215
  21. endif
  22. REGISTRY_NAME = quay.io
  23. BASEIMAGE = $(REGISTRY_NAME)/ceph/ceph-$(GOARCH):$(CEPH_VERSION)
  24. CEPH_IMAGE = $(BUILD_REGISTRY)/ceph-$(GOARCH)
  25. OPERATOR_SDK_VERSION = v1.25.0
  26. # TODO: update to yq v4 - v3 end of life in Aug 2021 ; v4 removes the 'yq delete' cmd and changes syntax
  27. YQv3_VERSION = 3.4.1
  28. GOHOST := GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go
  29. MANIFESTS_DIR=../../deploy/examples
  30. TEMP := $(shell mktemp -d)
  31. # Note: as of version 1.3 of operator-sdk, the url format changed to:
  32. # ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
  33. # (see: https://sdk.operatorframework.io/docs/installation/)
  34. S5CMD_ARCH = Linux-64bit
  35. ifeq ($(REAL_HOST_PLATFORM),linux_amd64)
  36. OPERATOR_SDK_PLATFORM = x86_64-linux-gnu
  37. INCLUDE_CSV_TEMPLATES = true
  38. endif
  39. ifeq ($(REAL_HOST_PLATFORM),linux_arm64)
  40. OPERATOR_SDK_PLATFORM = aarch64-linux-gnu
  41. INCLUDE_CSV_TEMPLATES = true
  42. S5CMD_ARCH = Linux-arm64
  43. endif
  44. ifeq ($(REAL_HOST_PLATFORM),darwin_amd64)
  45. OPERATOR_SDK_PLATFORM = x86_64-apple-darwin
  46. INCLUDE_CSV_TEMPLATES = true
  47. endif
  48. ifneq ($(INCLUDE_CSV_TEMPLATES),true)
  49. $(info )
  50. $(info NOT INCLUDING OLM/CSV TEMPLATES!)
  51. $(info )
  52. endif
  53. # s5cmd's version
  54. S5CMD_VERSION = 2.2.1
  55. OPERATOR_SDK := $(TOOLS_HOST_DIR)/operator-sdk-$(OPERATOR_SDK_VERSION)
  56. YQv3 := $(TOOLS_HOST_DIR)/yq-$(YQv3_VERSION)
  57. export OPERATOR_SDK YQv3
  58. # ====================================================================================
  59. # Build Rook
  60. do.build:
  61. @echo === container build $(CEPH_IMAGE)
  62. @cp Dockerfile $(TEMP)
  63. @cp toolbox.sh $(TEMP)
  64. @cp set-ceph-debug-level $(TEMP)
  65. @cp $(OUTPUT_DIR)/bin/linux_$(GOARCH)/rook $(TEMP)
  66. @cp -r $(MANIFESTS_DIR)/monitoring $(TEMP)/ceph-monitoring
  67. @mkdir -p $(TEMP)/rook-external/test-data
  68. @cp $(MANIFESTS_DIR)/create-external-cluster-resources.* $(TEMP)/rook-external/
  69. @cp ../../tests/ceph-status-out $(TEMP)/rook-external/test-data/
  70. ifeq ($(INCLUDE_CSV_TEMPLATES),true)
  71. @$(MAKE) csv
  72. @cp -r ../../build/csv $(TEMP)/ceph-csv-templates
  73. @rm $(TEMP)/ceph-csv-templates/csv-gen.sh
  74. @$(MAKE) csv-clean
  75. else
  76. mkdir $(TEMP)/ceph-csv-templates
  77. endif
  78. @cd $(TEMP) && $(SED_IN_PLACE) 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
  79. @if [ -z "$(BUILD_CONTAINER_IMAGE)" ]; then\
  80. $(DOCKERCMD) build $(BUILD_ARGS) \
  81. --build-arg S5CMD_VERSION=$(S5CMD_VERSION) \
  82. --build-arg S5CMD_ARCH=$(S5CMD_ARCH) \
  83. -t $(CEPH_IMAGE) \
  84. $(TEMP);\
  85. fi
  86. @rm -fr $(TEMP)
  87. # call this before building multiple arches in parallel to prevent parallel build processes from
  88. # conflicting
  89. prerequisites: $(OPERATOR_SDK) $(YQv3)
  90. $(YQv3):
  91. @echo === installing yq $(YQv3_VERSION) $(REAL_HOST_PLATFORM)
  92. @mkdir -p $(TOOLS_HOST_DIR)
  93. @curl -JL https://github.com/mikefarah/yq/releases/download/$(YQv3_VERSION)/yq_$(REAL_HOST_PLATFORM) -o $(YQv3)
  94. @chmod +x $(YQv3)
  95. $(OPERATOR_SDK):
  96. @echo === installing operator-sdk $(REAL_HOST_PLATFORM)
  97. @mkdir -p $(TOOLS_HOST_DIR)
  98. @curl -JL -o $(TOOLS_HOST_DIR)/operator-sdk-$(OPERATOR_SDK_VERSION) \
  99. https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(REAL_HOST_PLATFORM)
  100. @chmod +x $(OPERATOR_SDK)
  101. @$(OPERATOR_SDK) version
  102. csv: $(OPERATOR_SDK) $(YQv3)
  103. @echo generate csv with latest operator-sdk
  104. @mkdir -p ../../build/csv/ceph
  105. @../../build/csv/csv-gen.sh
  106. @# #adding 2>/dev/null since CI doesn't seems to be creating bundle.Dockerfile file
  107. @rm bundle.Dockerfile 2> /dev/null || true
  108. csv-clean: ## Remove existing OLM files.
  109. @rm -fr ../../build/csv/ceph/${go env GOARCH}
  110. @rm -f ../../build/csv/rook-ceph.clusterserviceversion.yaml
  111. @git restore $(MANIFESTS_DIR)/crds.yaml ../../deploy/charts/rook-ceph/templates/resources.yaml
  112. # reading from a file and outputting to the same file can have undefined results, so use this intermediate
  113. IMAGE_TMP="/tmp/rook-ceph-image-list"
  114. list-image: ## Create a list of images for offline installation
  115. @echo "producing list of images for offline installation"
  116. rm -f $(IMAGE_TMP)
  117. awk '/image:/ {print $2}' $(MANIFESTS_DIR)/operator.yaml $(MANIFESTS_DIR)/cluster.yaml | \
  118. cut -d: -f2- | tee $(IMAGE_TMP)
  119. awk '/quay.io/ || /registry.k8s.io/ {print $3}' ../../pkg/operator/ceph/csi/spec.go | \
  120. cut -d= -f2- | tr -d '"' | tee -a $(IMAGE_TMP)
  121. awk '/quay.io/ || /gcr.io/ {print $4}' ../../pkg/operator/ceph/object/cosi/spec.go | \
  122. cut -d= -f2- | tr -d '"' | tee -a $(IMAGE_TMP)
  123. rm -f $(MANIFESTS_DIR)/images.txt
  124. cat $(IMAGE_TMP) | sort -h | uniq | tee $(MANIFESTS_DIR)/images.txt
  125. rm -f $(IMAGE_TMP)