generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 534
/
Makefile
110 lines (93 loc) · 3.29 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
# 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.
GO_VERSION := $(shell awk '/^go /{print $$2}' go.mod|head -n1)
INTEGTESTENVVAR=SCHED_PLUGINS_TEST_VERBOSE=1
# Manage platform and builders
PLATFORMS ?= linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
BUILDER ?= docker
ifeq ($(BUILDER),podman)
ALL_FLAG=--all
else
ALL_FLAG=
endif
# REGISTRY is the container registry to push
# into. The default is to push to the staging
# registry, not production(registry.k8s.io).
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_CONTROLLER_IMAGE:=controller:$(RELEASE_VERSION)
GO_BASE_IMAGE?=golang:$(GO_VERSION)
DISTROLESS_BASE_IMAGE?=gcr.io/distroless/static:nonroot
EXTRA_ARGS=""
# VERSION is the scheduler'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}')
VERSION:=$(or $(VERSION),v0.0.$(shell date +%Y%m%d))
.PHONY: all
all: build
.PHONY: build
build: build-controller build-scheduler
.PHONY: build-controller
build-controller:
$(GO_BUILD_ENV) go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/controller cmd/controller/controller.go
.PHONY: build-scheduler
build-scheduler:
$(GO_BUILD_ENV) go build -ldflags '-X k8s.io/component-base/version.gitVersion=$(VERSION) -w' -o bin/kube-scheduler cmd/scheduler/main.go
.PHONY: build-images
build-images:
BUILDER=$(BUILDER) \
PLATFORMS=$(PLATFORMS) \
RELEASE_VERSION=$(RELEASE_VERSION) \
REGISTRY=$(REGISTRY) \
IMAGE=$(RELEASE_IMAGE) \
CONTROLLER_IMAGE=$(RELEASE_CONTROLLER_IMAGE) \
GO_BASE_IMAGE=$(GO_BASE_IMAGE) \
DISTROLESS_BASE_IMAGE=$(DISTROLESS_BASE_IMAGE) \
DOCKER_BUILDX_CMD=$(DOCKER_BUILDX_CMD) \
EXTRA_ARGS=$(EXTRA_ARGS) hack/build-images.sh
.PHONY: local-image
local-image: PLATFORMS="linux/$$(uname -m)"
local-image: RELEASE_VERSION="v0.0.0"
local-image: REGISTRY="localhost:5000/scheduler-plugins"
local-image: EXTRA_ARGS="--load"
local-image: clean build-images
.PHONY: release-images
push-images: EXTRA_ARGS="--push"
push-images: build-images
.PHONY: update-gomod
update-gomod:
hack/update-gomod.sh
.PHONY: unit-test
unit-test: install-envtest
hack/unit-test.sh $(ARGS)
.PHONY: install-envtest
install-envtest:
hack/install-envtest.sh
.PHONY: integration-test
integration-test: install-envtest
$(INTEGTESTENVVAR) hack/integration-test.sh $(ARGS)
.PHONY: verify
verify:
hack/verify-gomod.sh
hack/verify-gofmt.sh
hack/verify-crdgen.sh
hack/verify-structured-logging.sh
hack/verify-toc.sh
.PHONY: clean
clean:
rm -rf ./bin