forked from kubean-io/kubean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (103 loc) · 4.09 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
# Copyright 2023 Authors of kubean-io
# SPDX-License-Identifier: Apache-2.0
GOARCH ?= $(shell go env GOARCH)
BUILD_ARCH ?= linux/$(GOARCH)
VERSION?=""
ifeq ($(VERSION), "")
LATEST_TAG=$(shell git describe --tags --abbrev=8)
ifeq ($(LATEST_TAG),)
# Forked repo may not sync tags from upstream, so give it a default tag to make CI happy.
VERSION="unknown"
else
VERSION=$(LATEST_TAG)
endif
endif
# convert to git version to semver version v0.1.1-14-gb943a40 --> v0.1.1+14-gb943a40
KUBEAN_VERSION := $(shell echo $(VERSION) | sed 's/-/+/1')
# convert to git version to semver version v0.1.1+14-gb943a40 --> v0.1.1-14-gb943a40
KUBEAN_IMAGE_VERSION := $(shell echo $(KUBEAN_VERSION) | sed 's/+/-/1')
#v0.1.1 --> 0.1.1 Match the helm chart version specification, remove the preceding prefix `v` character
KUBEAN_CHART_VERSION := $(shell echo ${KUBEAN_VERSION} |sed 's/^v//g' )
REGISTRY_SERVER_ADDRESS?=container.io
REGISTRY_REPO?=$(REGISTRY_SERVER_ADDRESS)/kubean-ci
SPRAY_TAG?="latest"
.PHONY: test
test:
bash hack/unit-test.sh
.PHONY: staticcheck
staticcheck:
hack/staticcheck.sh
.PHONY: update
update:
cd ./api/ && make update && cd .. && go mod tidy && go mod vendor
.PHONY: kubean-operator
kubean-operator: $(SOURCES)
echo "Building kubean-operator for arch = $(BUILD_ARCH)"
export DOCKER_CLI_EXPERIMENTAL=enabled ;\
! ( docker buildx ls | grep kubean-operator-multi-platform-builder ) && docker buildx create --use --platform=$(BUILD_ARCH) --name kubean-operator-multi-platform-builder ;\
docker buildx build \
--build-arg kubean_version=$(KUBEAN_VERSION) \
--builder kubean-operator-multi-platform-builder \
--platform $(BUILD_ARCH) \
--tag $(REGISTRY_REPO)/kubean-operator:$(KUBEAN_IMAGE_VERSION) \
--tag $(REGISTRY_REPO)/kubean-operator:latest \
-f ./build/images/kubean-operator/Dockerfile \
--load \
.
.PHONY: kubean-admission
kubean-admission: $(SOURCES)
echo "Building kubean-admission for arch = $(BUILD_ARCH)"
export DOCKER_CLI_EXPERIMENTAL=enabled ;\
! ( docker buildx ls | grep kubean-admission-multi-platform-builder ) && docker buildx create --use --platform=$(BUILD_ARCH) --name kubean-admission-multi-platform-builder ;\
docker buildx build \
--build-arg kubean_version=$(KUBEAN_VERSION) \
--builder kubean-admission-multi-platform-builder \
--platform $(BUILD_ARCH) \
--tag $(REGISTRY_REPO)/kubean-admission:$(KUBEAN_IMAGE_VERSION) \
--tag $(REGISTRY_REPO)/kubean-admission:latest \
-f ./build/images/kubean-admission/Dockerfile \
--load \
.
.PHONY: spray-job
spray-job: $(SOURCES)
echo "Building spray-job for arch = $(BUILD_ARCH)"
export DOCKER_CLI_EXPERIMENTAL=enabled ;\
! ( docker buildx ls | grep spray-job-multi-platform-builder ) && docker buildx create --use --platform=$(BUILD_ARCH) --name spray-job-multi-platform-builder ;\
docker buildx build \
--build-arg SPRAY_TAG=$(SPRAY_TAG) \
--builder spray-job-multi-platform-builder \
--platform $(BUILD_ARCH) \
--tag $(REGISTRY_REPO)/spray-job:$(KUBEAN_IMAGE_VERSION) \
--tag $(REGISTRY_REPO)/spray-job:latest \
-f ./build/images/spray-job/Dockerfile \
--load \
.
IMAGE_REGISTRY ?= "ghcr.m.daocloud.io"
RELEASE_NAME ?= "kubean"
TARGET_NS ?= "kubean-system"
KUBECONFIG_PATH ?= "kubeconfig"
GIT_VERSION ?= $(shell git describe --tags --abbrev=8)
IMAGE_TAG ?= ${GIT_VERSION}
.PHONY: local-chart-to-deploy
local-chart-to-deploy:
bash hack/local-chart-to-deploy.sh ${IMAGE_REGISTRY} ${RELEASE_NAME} ${TARGET_NS} ${KUBECONFIG_PATH} ${IMAGE_TAG} ${GIT_VERSION}
.PHONY: security-scanning
security-scanning:
bash hack/trivy.sh \
${REGISTRY}/${REPO}/spray-job:${IMAGE_TAG} \
${REGISTRY}/${REPO}/kubean-operator:${IMAGE_TAG} \
${REGISTRY}/${REPO}/kubespray:${SPRAY_IMAGE_TAG_SHORT_SHA}
.PHONY: helmdoc
helmdoc:
ifeq (, $(shell which readme-generator))
@{ \
set -e ;\
echo 'installing readme-generator-for-helm' ;\
npm install -g @bitnami/readme-generator-for-helm ;\
}
else
@echo readme-generator-for-helm is already installed
HELMDOC=$(shell which readme-generator)
endif
helm-doc-gen: helmdoc
readme-generator -v charts/kubean/values.yaml -r charts/kubean/README.md