forked from gardener/machine-controller-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
199 lines (157 loc) · 6.74 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
# Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
#
# 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.
IMAGE_REPOSITORY := eu.gcr.io/gardener-project/gardener/machine-controller-manager
IMAGE_TAG := $(shell cat VERSION)
COVERPROFILE := test/output/coverprofile.out
CONTROL_NAMESPACE := default
CONTROL_KUBECONFIG := dev/target-kubeconfig.yaml
TARGET_KUBECONFIG := dev/target-kubeconfig.yaml
#########################################
# Rules for local development scenarios #
#########################################
.PHONY: start
start:
@go run cmd/machine-controller-manager/controller_manager.go \
--control-kubeconfig=$(CONTROL_KUBECONFIG) \
--target-kubeconfig=$(TARGET_KUBECONFIG) \
--namespace=$(CONTROL_NAMESPACE) \
--safety-up=2 \
--safety-down=1 \
--machine-drain-timeout=5 \
--machine-health-timeout=10 \
--machine-set-scale-timeout=20 \
--machine-safety-orphan-vms-period=30 \
--machine-safety-overshooting-period=1 \
--v=2
#################################################################
# Rules related to binary build, Docker image build and release #
#################################################################
.PHONY: revendor
revendor:
@dep ensure -update
.PHONY: build
build:
@.ci/build
.PHONY: build-local
build-local:
@env LOCAL_BUILD=1 .ci/build
.PHONY: release
release: build build-local docker-image docker-login docker-push rename-binaries
.PHONY: docker-image
docker-images:
@if [[ ! -f bin/rel/machine-controller-manager ]]; then echo "No binary found. Please run 'make build'"; false; fi
@docker build -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) --rm .
.PHONY: docker-login
docker-login:
@gcloud auth activate-service-account --key-file .kube-secrets/gcr/gcr-readwrite.json
.PHONY: docker-push
docker-push:
@if ! docker images $(IMAGE_REPOSITORY) | awk '{ print $$2 }' | grep -q -F $(IMAGE_TAG); then echo "$(IMAGE_REPOSITORY) version $(IMAGE_TAG) is not yet built. Please run 'make docker-images'"; false; fi
@gcloud docker -- push $(IMAGE_REPOSITORY):$(IMAGE_TAG)
.PHONY: rename-binaries
rename-binaries:
@if [[ -f bin/machine-controller-manager ]]; then cp bin/machine-controller-manager machine-controller-manager-darwin-amd64; fi
@if [[ -f bin/rel/machine-controller-manager ]]; then cp bin/rel/machine-controller-manager machine-controller-manager-linux-amd64; fi
.PHONY: clean
clean:
@rm -rf bin/
@rm -f *linux-amd64
@rm -f *darwin-amd64
#####################################################################
# Rules for verification, formatting, linting, testing and cleaning #
#####################################################################
.PHONY: verify
verify: check test
.PHONY: check
check:
@.ci/check
.PHONY: test
test:
@.ci/test
.PHONY: test-unit
test-unit:
@SKIP_INTEGRATION_TESTS=X .ci/test
.PHONY: test-integration
test-integration:
@SKIP_UNIT_TESTS=X .ci/test
.PHONY: show-coverage
show-coverage:
@if [ ! -f $(COVERPROFILE) ]; then echo "$(COVERPROFILE) is not yet built. Please run 'COVER=true make test'"; false; fi
go tool cover -html $(COVERPROFILE)
.PHONY: test-clean
test-clean:
@find . -name "*.coverprofile" -type f -delete
@rm -f machine-controller-manager.coverage.html
### Adopted from cluster-api ###
.PHONY: genapi genconversion genclientset gendeepcopy
all: generate build images
depend:
dep version || go get -u github.com/golang/dep/cmd/dep
dep ensure -v
# go libraries often ship BUILD and BUILD.bazel files, but they often don't work.
# We delete them and regenerate them
find vendor -name "BUILD" -delete
find vendor -name "BUILD.bazel" -delete
bazel run //:gazelle
generate: genapi genconversion genclientset gendeepcopy genopenapi
genapi:
go build -o $$GOPATH/bin/apiregister-gen ../../../sigs.k8s.io/cluster-api/vendor/github.com/kubernetes-incubator/apiserver-builder/cmd/apiregister-gen
$$GOPATH/bin/apiregister-gen -i ./pkg/apis,./pkg/apis/cluster,./pkg/apis/cluster/v1alpha1
genconversion:
go build -o $$GOPATH/bin/conversion-gen ../../../sigs.k8s.io/cluster-api/vendor/k8s.io/code-generator/cmd/conversion-gen
$$GOPATH/bin/conversion-gen -i ./pkg/apis/cluster/v1alpha1/ -O zz_generated.conversion --go-header-file boilerplate.go.txt
genclientset:
go build -o $$GOPATH/bin/client-gen ../../../sigs.k8s.io/cluster-api/vendor/k8s.io/code-generator/cmd/client-gen
client-gen \
--input="cluster/v1alpha1" \
--clientset-name="clientset" \
--input-base="sigs.k8s.io/cluster-api/pkg/apis" \
--output-package "sigs.k8s.io/cluster-api/pkg/client/clientset_generated" \
--go-header-file boilerplate.go.txt \
--clientset-path sigs.k8s.io/cluster-api/pkg/client/clientset_generated
gendeepcopy:
go build -o $$GOPATH/bin/deepcopy-gen ../../../sigs.k8s.io/cluster-api/vendor/k8s.io/code-generator/cmd/deepcopy-gen
$$GOPATH/bin/deepcopy-gen \
-i ./pkg/apis/cluster/,./pkg/apis/cluster/v1alpha1/ \
-O zz_generated.deepcopy \
-h boilerplate.go.txt
STATIC_API_DIRS = k8s.io/apimachinery/pkg/apis/meta/v1
STATIC_API_DIRS += k8s.io/apimachinery/pkg/api/resource
STATIC_API_DIRS += k8s.io/apimachinery/pkg/version
STATIC_API_DIRS += k8s.io/apimachinery/pkg/runtime
STATIC_API_DIRS += k8s.io/apimachinery/pkg/util/intstr
STATIC_API_DIRS += k8s.io/api/core/v1
# Automatically extract vendored apis under vendor/k8s.io/api.
VENDOR_API_DIRS := $(shell find vendor/k8s.io/api -type d | grep -E 'v[[:digit:]]+(alpha[[:digit:]]+|beta[[:digit:]]+)*' | sed -e 's/^vendor\///')
empty:=
comma:=,
space:=$(empty) $(empty)
genopenapi: static_apis = $(subst $(space),$(comma),$(STATIC_API_DIRS))
genopenapi: vendor_apis = $(subst $(space),$(comma),$(VENDOR_API_DIRS))
genopenapi:
go build -o $$GOPATH/bin/openapi-gen sigs.k8s.io/cluster-api/vendor/k8s.io/code-generator/cmd/openapi-gen
openapi-gen \
--input-dirs $(static_apis) \
--input-dirs $(vendor_apis) \
--input-dirs ./pkg/apis/cluster/,./pkg/apis/cluster/v1alpha1/ \
--output-package "sigs.k8s.io/cluster-api/pkg/openapi" \
--go-header-file boilerplate.go.txt
build: depend
CGO_ENABLED=0 go install -a -ldflags '-extldflags "-static"' sigs.k8s.io/cluster-api/cmd/apiserver
CGO_ENABLED=0 go install -a -ldflags '-extldflags "-static"' sigs.k8s.io/cluster-api/cmd/controller-manager
images: depend
$(MAKE) -C cmd/apiserver image
$(MAKE) -C cmd/controller-manager image
verify:
./hack/verify_boilerplate.py