forked from aws/eks-distro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
278 lines (229 loc) · 9.62 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
BASE_DIRECTORY:=$(shell git rev-parse --show-toplevel)
RELEASE_BRANCH?=$(shell cat $(BASE_DIRECTORY)/release/DEFAULT_RELEASE_BRANCH)
SUPPORTED_RELEASE_BRANCHES?=$(shell cat $(BASE_DIRECTORY)/release/SUPPORTED_RELEASE_BRANCHES)
RELEASE_ENVIRONMENT?=development
RELEASE?=$(shell cat $(BASE_DIRECTORY)/release/$(RELEASE_BRANCH)/$(RELEASE_ENVIRONMENT)/RELEASE)
PROD_RELEASE=$(shell cat $(BASE_DIRECTORY)/release/$(RELEASE_BRANCH)/production/RELEASE)
OVERRIDE_NUMBER?=-1
WITH_GIT_AND_PR=true
ARTIFACT_BUCKET?=my-s3-bucket
AWS_ACCOUNT_ID?=$(shell aws sts get-caller-identity --query Account --output text)
AWS_REGION?=us-west-2
IMAGE_REPO?=$(if $(AWS_ACCOUNT_ID),$(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com,localhost:5000)
RELEASE_AWS_PROFILE?=default
RELEASE_GIT_TAG?=v$(RELEASE_BRANCH)-eks-$(PROD_RELEASE)
RELEASE_GIT_COMMIT_HASH?=$(shell git rev-parse @)
REBUILD_ALL?=false
ALL_PROJECTS=containernetworking_plugins coredns_coredns etcd-io_etcd kubernetes-csi_external-attacher kubernetes-csi_external-resizer \
kubernetes-csi_livenessprobe kubernetes-csi_node-driver-registrar kubernetes-sigs_aws-iam-authenticator kubernetes-sigs_metrics-server \
kubernetes-csi_external-snapshotter kubernetes-csi_external-provisioner kubernetes_release kubernetes_kubernetes \
kubernetes_cloud-provider-aws
ifdef MAKECMDGOALS
TARGET=$(MAKECMDGOALS)
else
TARGET=$(DEFAULT_GOAL)
endif
.PHONY: setup
setup:
development/ecr/ecr-command.sh install-ecr-public
development/ecr/ecr-command.sh login-ecr-public
# For components which build the same versions across multiple kube versions
# we use the first version which has the same git_tag as the current project build
# as the buildctl import-cache to try and converge as many builds to the same image in ecr
# This isnt neccessary since on the subsequent builds they should converge, but building
# kube first for newer versions while build all other components gives us the best chance
# to converge on the same image in the first build. This also doesnt handle cases where the
# first version is different but the next 3 are the same, in those cases it would still
# take two builds to converge
.PHONY: build
build:
go vet cmd/main_postsubmit.go
go run cmd/main_postsubmit.go \
--target=build \
--release-branch=${RELEASE_BRANCH} \
--release=${RELEASE} \
--region=${AWS_REGION} \
--account-id=${AWS_ACCOUNT_ID} \
--image-repo=${IMAGE_REPO} \
--dry-run=true \
--rebuild-all=${REBUILD_ALL} \
--build-kubernetes-first=$(if $(filter $(RELEASE_BRANCH),$(firstword $(SUPPORTED_RELEASE_BRANCHES))),false,true)
@echo 'Done' $(TARGET)
.PHONY: postsubmit-build
postsubmit-build: setup
go vet cmd/main_postsubmit.go
go run cmd/main_postsubmit.go \
--target=release,clean,clean-go-cache \
--release-branch=${RELEASE_BRANCH} \
--release=${RELEASE} \
--region=${AWS_REGION} \
--account-id=${AWS_ACCOUNT_ID} \
--image-repo=${IMAGE_REPO} \
--artifact-bucket=$(ARTIFACT_BUCKET) \
--dry-run=false \
--rebuild-all=${REBUILD_ALL}
.PHONY: kops
kops: export UBUNTU_RELEASE=focal-20.04
kops: $(if $(CODEBUILD_BUILD_ID),kops-codebuild,kops-prow)
.PHONY: kops-codebuild
kops-codebuild: KOPS_ENTRYPOINT=development/kops/codebuild.sh
kops-codebuild: kops-amd kops-arm
@echo 'Done kops-codebuild'
.PHONY: kops-prow
kops-prow: KOPS_ENTRYPOINT=development/kops/prow.sh
kops-prow: kops-amd kops-arm
@echo 'Done kops-prow'
.PHONY: kops-amd
kops-amd: kops-prereqs
RELEASE=$(RELEASE) $(KOPS_ENTRYPOINT)
.PHONY: kops-arm
kops-arm: export NODE_INSTANCE_TYPE=t4g.medium
kops-arm: export NODE_ARCHITECTURE=arm64
kops-arm: kops-prereqs
export IPV6=true; \
sleep 5m; \
RELEASE=$(RELEASE) $(KOPS_ENTRYPOINT);
.PHONY: kops-arm-ubuntu-22
kops-arm-ubuntu-22: export UBUNTU_RELEASE=jammy-22.04
kops-arm-ubuntu-22: kops-prereqs
sleep 10m; \
RELEASE=$(RELEASE) $(KOPS_ENTRYPOINT);
.PHONY: kops-prereqs
kops-prereqs: $(if $(filter presubmit,$(JOB_TYPE)),,postsubmit-build)
ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""
cd development/kops && RELEASE=$(RELEASE) ./install_requirements.sh
.PHONY: postsubmit-conformance
postsubmit-conformance: RELEASE:=$(shell echo $$(($(RELEASE) + 1))).pre
postsubmit-conformance: postsubmit-build kops
@echo 'Done postsubmit-conformance'
.PHONY: tag
tag:
git tag -a $(RELEASE_GIT_TAG) $(RELEASE_GIT_COMMIT_HASH) -m $(RELEASE_GIT_TAG)
git push upstream $(RELEASE_GIT_TAG)
.PHONY: upload
upload:
release/generate_crd.sh $(RELEASE_BRANCH) $(RELEASE) $(IMAGE_REPO)
release/s3_sync.sh $(RELEASE_BRANCH) $(RELEASE) $(ARTIFACT_BUCKET) true
@echo 'Done' $(TARGET)
.PHONY: release
release: $(addprefix makes-release-, $(ALL_PROJECTS)) upload
@echo 'Done' $(TARGET)
.PHONY: makes-release-%
makes-release-%:
$(eval PROJECT_PATH=projects/$(subst _,/,$*))
$(MAKE) release clean clean-go-cache -C $(PROJECT_PATH)
.PHONY: binaries
binaries: $(addprefix makes-binaries-, $(ALL_PROJECTS))
@echo 'Done' $(TARGET)
.PHONY: makes-binaries-%
makes-binaries-%:
$(eval PROJECT_PATH=projects/$(subst _,/,$*))
$(MAKE) binaries -C $(PROJECT_PATH)
.PHONY: run-target-in-docker
run-target-in-docker:
build/lib/run_target_docker.sh $(PROJECT) $(MAKE_TARGET) $(IMAGE_REPO) $(RELEASE_BRANCH)
.PHONY: stop-docker-builder
stop-docker-builder:
docker rm -f -v eks-d-builder
.PHONY: run-buildkit-and-registry
run-buildkit-and-registry:
docker run -d --name buildkitd --net host --privileged moby/buildkit:v0.12.3
docker run -d --name registry --net host registry:2
.PHONY: stop-buildkit-and-registry
stop-buildkit-and-registry:
docker rm -v --force buildkitd
docker rm -v --force registry
.PHONY: clean
clean: $(addprefix makes-clean-, $(ALL_PROJECTS))
@echo 'Done' $(TARGET)
.PHONY: makes-clean-%
makes-clean-%:
$(eval PROJECT_PATH=projects/$(subst _,/,$*))
$(MAKE) clean -C $(PROJECT_PATH)
.PHONY: attribution-files
attribution-files: $(addprefix attribution-files-project-, $(ALL_PROJECTS))
cat _output/total_summary.txt
.PHONY: attribution-files-project-%
attribution-files-project-%:
$(eval PROJECT_PATH=projects/$(subst _,/,$*))
$(MAKE) -C $(PROJECT_PATH) all-attributions
.PHONY: update-attribution-files
update-attribution-files: add-generated-help-block go-mod-files attribution-files
build/update-attribution-files/create_pr.sh
.PHONY: checksum-files-project-%
checksum-files-project-%:
$(eval PROJECT_PATH=projects/$(subst _,/,$*))
$(MAKE) -C $(PROJECT_PATH) all-checksums
.PHONY: update-checksum-files
update-checksum-files: $(addprefix checksum-files-project-, $(ALL_PROJECTS))
build/lib/update_go_versions.sh
build/update-attribution-files/create_pr.sh
.PHONY: go-mod-files-project-%
go-mod-files-project-%:
$(eval PROJECT_PATH=projects/$(subst _,/,$*))
$(MAKE) -C $(PROJECT_PATH) all-update-go-mods
.PHONY: go-mod-files
go-mod-files: $(addprefix go-mod-files-project-, $(ALL_PROJECTS))
build/update-attribution-files/create_pr.sh
.PHONY: add-generated-help-block-project-%
add-generated-help-block-project-%:
$(eval PROJECT_PATH=projects/$(subst _,/,$*))
$(MAKE) add-generated-help-block -C $(PROJECT_PATH) RELEASE_BRANCH=1-26
.PHONY: add-generated-help-block
add-generated-help-block: $(addprefix add-generated-help-block-project-, $(ALL_PROJECTS))
build/update-attribution-files/create_pr.sh
.PHONY: update-release-number
update-release-number:
go vet ./cmd/release/number
go run ./cmd/release/number/main.go \
--branch=$(RELEASE_BRANCH) \
--isProd=$(is_update_prod_number)
.PHONY: update-dev-release-number
update-dev-release-number:
$(MAKE) is_update_prod_number=false update-release-number
.PHONY: update-prod-release-number
update-prod-release-number:
$(MAKE) is_update_prod_number=true update-release-number
.PHONY: update-release-numbers
update-release-numbers: update-dev-release-number update-prod-release-number
.PHONY: update-all-release-numbers
update-all-release-numbers:
for r_b in $(SUPPORTED_RELEASE_BRANCHES); do RELEASE_BRANCH=$$r_b $(MAKE) update-release-numbers; done
# See important note about minor releases in the Go function called.
# release-docs is intended to be used to generate release docs for the latest release branch. If this command is used in
# conjunction with release-docs-limited to make all the release docs for a new minor release, WITH_GIT_AND_PR should be
# set to false, as presumably there are additional changes that have been made by multiple run of release-docs-limited.
.PHONY: release-docs
release-docs:
go vet ./cmd/release/docs
go run ./cmd/release/docs/main.go \
--branch=$(RELEASE_BRANCH) \
--manageGitAndOpenPR=$(WITH_GIT_AND_PR)
# See important note about minor releases in the Go function called.
# release-docs-limited is intended to be used to generate docs for multiple release for new minor releases. This make
# command should be run for all releases from 1 until *** one less than *** the latest prod number. For example, if the
# prod release number is 4, it should be run 3 times and the overrideNumber flag should be used to set the release
# number to 1, then 2, then 3. For the latest release (which is 4 in the example), make release-docs should be used
# instead of release-docs-limited. See that make command's comment for additional information
.PHONY: release-docs-limited
release-docs-limited:
go vet ./cmd/release/docs
go run ./cmd/release/docs/main.go \
--branch=$(RELEASE_BRANCH) \
--manageGitAndOpenPR=false \
--releaseAnnouncement=false \
--optionalOverrideNumber=$(OVERRIDE_NUMBER)
.PHONY: github-release
github-release:
go vet ./cmd/release/gh-release
go run ./cmd/release/gh-release/main.go \
--branch=$(RELEASE_BRANCH) \
--overrideNumber=$(OVERRIDE_NUMBER)
.PHONY: minor-release-foundation
minor-release-foundation:
go vet ./cmd/release/minor
go run ./cmd/release/minor/main.go
.PHONY: print-versions
print-versions:
go vet ./cmd/print-versions
go run ./cmd/print-versions/main.go