-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
127 lines (102 loc) · 5.56 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
# Copyright 2020 The Kubernetes Authors.
#
# 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.
ARCHS = amd64 arm64
COMMONENVVAR=GOOS=$(shell uname -s | tr A-Z a-z)
BUILDENVVAR=CGO_ENABLED=0
LOCAL_REGISTRY=localhost:5000/scheduler-plugins
LOCAL_IMAGE=kube-scheduler:latest
# RELEASE_REGISTRY is the container registry to push
# into. The default is to push to the staging
# registry, not production(k8s.gcr.io).
RELEASE_REGISTRY?=gcr.io/k8s-staging-scheduler-plugins
RELEASE_VERSION?=v$(shell date +%Y%m%d)-$(shell git describe --tags --match "v*")
RELEASE_IMAGE:=kube-scheduler:$(RELEASE_VERSION)
RELEASE_DESCHEDULER_IMAGE:=descheduler:$(RELEASE_VERSION)
# VERSION is the multicluster's version
#
# The RELEASE_VERSION variable can have one of two formats:
# v20201009-v0.18.800-46-g939c1c0 - automated build for a commit(not a tag) and also a local build
# v20200521-v0.18.800 - automated build for a tag
VERSION=$(shell echo $(RELEASE_VERSION) | awk -F - '{print $$2}')
.PHONY: all
all: build
.PHONY: build
build: build-scheduler
.PHONY: build.amd64
build.amd64: build-scheduler.amd64
.PHONY: build.arm64v8
build.arm64v8: build-scheduler.arm64v8
.PHONY: build-scheduler build-descheduler
build-scheduler: autogen
$(COMMONENVVAR) $(BUILDENVVAR) go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/kube-scheduler cmd/scheduler/main.go
build-descheduler: autogen
$(COMMONENVVAR) $(BUILDENVVAR) go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/descheduler cmd/descheduler/descheduler.go
.PHONY: build-scheduler.amd64 build-descheduler.amd64
build-scheduler.amd64: autogen
$(COMMONENVVAR) $(BUILDENVVAR) GOARCH=amd64 go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/kube-scheduler cmd/scheduler/main.go
build-descheduler.amd64: autogen
$(COMMONENVVAR) $(BUILDENVVAR) GOARCH=amd64 go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/descheduler cmd/descheduler/descheduler.go
.PHONY: build-scheduler.arm64v8 build-descheduler.arm64v8
build-scheduler.arm64v8: autogen
GOOS=linux $(BUILDENVVAR) GOARCH=arm64 go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/kube-scheduler cmd/scheduler/main.go
build-descheduler.arm64v8: autogen
GOOS=linux $(BUILDENVVAR) GOARCH=arm64 go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/descheduler cmd/descheduler/descheduler.go
.PHONY: local-image
local-image: clean
docker build -f ./build/scheduler/Dockerfile --build-arg ARCH="amd64" --build-arg RELEASE_VERSION="$(RELEASE_VERSION)" -t $(LOCAL_REGISTRY)/$(LOCAL_IMAGE) .
docker build -f ./build/descheduler/Dockerfile --build-arg ARCH="amd64" -t $(LOCAL_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE) .
.PHONY: release-image.amd64
release-image.amd64: clean
docker build -f ./build/scheduler/Dockerfile --build-arg ARCH="amd64" --build-arg RELEASE_VERSION="$(RELEASE_VERSION)" -t $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-amd64 .
docker build -f ./build/descheduler/Dockerfile --build-arg ARCH="amd64" -t $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE)-amd64 .
.PHONY: release-image.arm64v8
release-image.arm64v8: clean
docker build -f ./build/scheduler/Dockerfile --build-arg ARCH="arm64v8" --build-arg RELEASE_VERSION="$(RELEASE_VERSION)" -t $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-arm64 .
docker build -f ./build/descheduler/Dockerfile --build-arg ARCH="arm64v8" -t $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE)-arm64 .
.PHONY: push-release-images
push-release-images: release-image.amd64 release-image.arm64v8
gcloud auth configure-docker
for arch in $(ARCHS); do \
docker push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-$${arch} ;\
docker push $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE)-$${arch} ;\
done
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(RELEASE_REGISTRY)/$(RELEASE_IMAGE) $(addprefix --amend $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-, $(ARCHS))
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE) $(addprefix --amend $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE)-, $(ARCHS))
for arch in $(ARCHS); do \
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest annotate --arch $${arch} $(RELEASE_REGISTRY)/$(RELEASE_IMAGE) $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-$${arch} ;\
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest annotate --arch $${arch} $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE) $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE)-$${arch} ;\
done
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE) ;\
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push $(RELEASE_REGISTRY)/$(RELEASE_DESCHEDULER_IMAGE) ;\
.PHONY: update-vendor
update-vendor:
hack/update-vendor.sh
.PHONY: unit-test
unit-test: autogen
hack/unit-test.sh
.PHONY: install-etcd
install-etcd:
hack/install-etcd.sh
.PHONY: autogen
autogen: update-vendor
hack/update-generated-openapi.sh
.PHONY: integration-test
integration-test: install-etcd autogen
hack/integration-test.sh
.PHONY: verify-gofmt
verify-gofmt:
hack/verify-gofmt.sh
.PHONY: clean
clean:
rm -rf ./bin