forked from grpc/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
275 lines (225 loc) · 8.06 KB
/
Makefile
File metadata and controls
275 lines (225 loc) · 8.06 KB
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
# Version tag for all images
TEST_INFRA_VERSION ?= "latest"
# Version of the gRPC driver
DRIVER_VERSION ?= "master"
# Prefix for all images used as clone and ready containers, enabling use with registries
# other than DockerHub
INIT_IMAGE_PREFIX ?= ""
# Prefix for all images used as build containers, enabling use with registries
# other than DockerHub
BUILD_IMAGE_PREFIX ?= ""
# Prefix for all images used as runtime containers, enabling use with registries
# other than DockerHub
IMAGE_PREFIX ?= ""
# Image URL to use all building/pushing image targets
CONTROLLER_IMG ?= ${IMAGE_PREFIX}controller:${TEST_INFRA_VERSION}
# Image URL to use all building/pushing image targets
CLEAN_IMG ?= ${IMAGE_PREFIX}cleanup:${TEST_INFRA_VERSION}
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
all: controller cleanup-agent runner
# Run tests
test: generate fmt vet manifests
go test ./... -coverprofile cover.out
# Build controller manager binary
controller: generate fmt vet
go build -trimpath -o bin/controller cmd/controller/main.go
# Build cleanup_agent manager binary
cleanup-agent: generate fmt vet
go build -trimpath -o bin/cleanup_agent cmd/cleanup_agent/main.go
# Build test runner tool
runner: fmt vet
go build -trimpath -o bin/runner cmd/runner/main.go
# Install CRDs into a cluster
install: manifests
kustomize build config/crd | kubectl apply -f -
# Uninstall CRDs from a cluster
uninstall: manifests
kustomize build config/crd | kubectl delete -f -
# Deploy both controller and cleanup_agent to the cluster
deploy: deploy-controller deploy-cleanup-agent
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy-controller: manifests
cd config/manager && kustomize edit set image controller=${CONTROLLER_IMG}
kustomize build config/default | kubectl apply -f -
# Deploy cleanup_agent in the configured Kubernetes cluster in ~/.kube/config
deploy-cleanup-agent: manifests
cd config/cleanup_agent && kustomize edit set image cleanup_agent=${CLEAN_IMG}
kustomize build config/cleanup_agent | kubectl apply -f -
# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." \
output:crd:artifacts:config=config/crd/bases
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
# Generate code
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
# Build the manager image with the controller
controller-image:
docker build -t ${CONTROLLER_IMG} -f containers/runtime/controller/Dockerfile .
# Build the manager image with the cleanup_agent
cleanup-agent-image:
docker build -t ${CLEAN_IMG} -f containers/runtime/cleanup_agent/Dockerfile .
# Push the controller manager image to a docker registry
push-controller-image:
docker push ${CONTROLLER_IMG}
# Push the cleanup-agent manager image to a docker registry
push-cleanup-agent-image:
docker push ${CLEAN_IMG}
# Build the clone init container image
clone-image:
docker build -t ${INIT_IMAGE_PREFIX}clone:${TEST_INFRA_VERSION} \
containers/init/clone
# Push the clone init container image to a docker registry
push-clone-image:
docker push ${INIT_IMAGE_PREFIX}clone:${TEST_INFRA_VERSION}
# Build the ready init container image
ready-image:
docker build -t ${INIT_IMAGE_PREFIX}ready:${TEST_INFRA_VERSION} \
-f containers/init/ready/Dockerfile .
# Push the ready init container image to a docker registry
push-ready-image:
docker push ${INIT_IMAGE_PREFIX}ready:${TEST_INFRA_VERSION}
# Build the driver container image at the $DRIVER_VERSION
driver-image:
docker build --build-arg GITREF=${DRIVER_VERSION} \
-t ${IMAGE_PREFIX}driver:${TEST_INFRA_VERSION} \
containers/runtime/driver
# Push the driver container image to a docker regisry
push-driver-image:
docker push ${IMAGE_PREFIX}driver:${TEST_INFRA_VERSION}
# Build the C++ runtime image
cxx-image:
docker build -t ${IMAGE_PREFIX}cxx:${TEST_INFRA_VERSION} containers/runtime/cxx
# Push the C++ runtime image to a docker registry
push-cxx-image:
docker push ${IMAGE_PREFIX}cxx:${TEST_INFRA_VERSION}
# Build the Go runtime image
go-image:
docker build -t ${IMAGE_PREFIX}go:${TEST_INFRA_VERSION} containers/runtime/go
# Push the Go runtime image to a docker registry
push-go-image:
docker push ${IMAGE_PREFIX}go:${TEST_INFRA_VERSION}
# Build the Node.js build image
node-build-image:
docker build -t ${BUILD_IMAGE_PREFIX}node:${TEST_INFRA_VERSION} containers/init/build/node
# Push the Node.js build image to a docker registry
push-node-build-image:
docker push ${BUILD_IMAGE_PREFIX}node:${TEST_INFRA_VERSION}
# Build the Node.js runtime image
node-image:
docker build -t ${IMAGE_PREFIX}node:${TEST_INFRA_VERSION} containers/runtime/node
# Push the Node.js runtime image to a docker registry
push-node-image:
docker push ${IMAGE_PREFIX}node:${TEST_INFRA_VERSION}
# Build the Java runtime image
java-image:
docker build -t ${IMAGE_PREFIX}java:${TEST_INFRA_VERSION} \
containers/runtime/java
# Push the Java runtime image to a docker registry
push-java-image:
docker push ${IMAGE_PREFIX}java:${TEST_INFRA_VERSION}
# Build the Ruby build image
ruby-build-image:
docker build -t ${BUILD_IMAGE_PREFIX}ruby:${TEST_INFRA_VERSION} \
containers/init/build/ruby
# Push the Ruby runtime image to a docker registry
push-ruby-build-image:
docker push ${BUILD_IMAGE_PREFIX}ruby:${TEST_INFRA_VERSION}
# Build the Ruby runtime image
ruby-image:
docker build -t ${IMAGE_PREFIX}ruby:${TEST_INFRA_VERSION} \
containers/runtime/ruby
# Push the Ruby runtime image to a docker registry
push-ruby-image:
docker push ${IMAGE_PREFIX}ruby:${TEST_INFRA_VERSION}
# Build the PHP build image
php-build-image:
docker build -t ${BUILD_IMAGE_PREFIX}php:${TEST_INFRA_VERSION} \
containers/init/build/php
# Push the PHP runtime image to a docker registry
push-php-build-image:
docker push ${BUILD_IMAGE_PREFIX}php:${TEST_INFRA_VERSION}
# Build the PHP runtime image
php-image:
docker build -t ${IMAGE_PREFIX}php:${TEST_INFRA_VERSION} \
containers/runtime/php
# Push the PHP runtime image to a docker registry
push-php-image:
docker push ${IMAGE_PREFIX}php:${TEST_INFRA_VERSION}
# Build the Python runtime image
python-image:
docker build -t ${IMAGE_PREFIX}python:${TEST_INFRA_VERSION} \
containers/runtime/python
# Push the Python runtime image to a docker registry
push-python-image:
docker push ${IMAGE_PREFIX}python:${TEST_INFRA_VERSION}
# Build the csharp build image
csharp-build-image:
docker build -t ${BUILD_IMAGE_PREFIX}csharp:${TEST_INFRA_VERSION} containers/init/build/csharp
# Push the csharp build image to a docker registry
push-csharp-build-image:
docker push ${BUILD_IMAGE_PREFIX}csharp:${TEST_INFRA_VERSION}
# Build all init container and runtime container images
all-images: \
clone-image \
ready-image \
driver-image \
cxx-image \
go-image \
java-image \
node-build-image \
node-image \
python-image \
php-build-image \
php-image \
ruby-build-image \
ruby-image \
csharp-build-image \
controller-image\
cleanup-agent-image
# Push all init container and runtime container images to a docker registry
push-all-images: \
push-clone-image \
push-ready-image \
push-driver-image \
push-cxx-image \
push-go-image \
push-node-build-image \
push-node-image \
push-java-image \
push-php-build-image \
push-php-image \
push-python-image \
push-ruby-build-image \
push-ruby-image \
push-csharp-build-image \
push-controller-image \
push-cleanup-agent-image
# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif