forked from k8sgateway/k8sgateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
615 lines (476 loc) · 23.9 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
#----------------------------------------------------------------------------------
# Base
#----------------------------------------------------------------------------------
ROOTDIR := $(shell pwd)
OUTPUT_DIR ?= $(ROOTDIR)/_output
# If you just put your username, then that refers to your account at hub.docker.com
IMAGE_REPO := quay.io/solo-io
# Kind of a hack to make sure _output exists
z := $(shell mkdir -p $(OUTPUT_DIR))
SOURCES := $(shell find . -name "*.go" | grep -v test.go)
RELEASE := "true"
ifeq ($(TAGGED_VERSION),)
TAGGED_VERSION := $(shell git describe --tags --dirty)
RELEASE := "false"
endif
VERSION ?= $(shell echo $(TAGGED_VERSION) | cut -c 2-)
ENVOY_GLOO_IMAGE ?= quay.io/solo-io/envoy-gloo:1.4.2
# The full SHA of the currently checked out commit
CHECKED_OUT_SHA := $(shell git rev-parse HEAD)
# Returns the name of the default branch in the remote `origin` repository, e.g. `master`
DEFAULT_BRANCH_NAME := $(shell git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
# Print the branches that contain the current commit and keep only the one that
# EXACTLY matches the name of the default branch (avoid matching e.g. `master-2`).
# If we get back a result, it mean we are on the default branch.
EMPTY_IF_NOT_DEFAULT := $(shell git branch --contains $(CHECKED_OUT_SHA) | grep -ow $(DEFAULT_BRANCH_NAME))
ON_DEFAULT_BRANCH := false
ifneq ($(EMPTY_IF_NOT_DEFAULT),)
ON_DEFAULT_BRANCH = true
endif
ASSETS_ONLY_RELEASE := true
ifeq ($(ON_DEFAULT_BRANCH), true)
ASSETS_ONLY_RELEASE = false
endif
print-git-info:
@echo CHECKED_OUT_SHA: $(CHECKED_OUT_SHA)
@echo DEFAULT_BRANCH_NAME: $(DEFAULT_BRANCH_NAME)
@echo EMPTY_IF_NOT_DEFAULT: $(EMPTY_IF_NOT_DEFAULT)
@echo ON_DEFAULT_BRANCH: $(ON_DEFAULT_BRANCH)
@echo ASSETS_ONLY_RELEASE: $(ASSETS_ONLY_RELEASE)
LDFLAGS := "-X github.com/solo-io/gloo/pkg/version.Version=$(VERSION)"
GCFLAGS := all="-N -l"
GO_BUILD_FLAGS := GO111MODULE=on CGO_ENABLED=0 GOARCH=amd64
# Passed by cloudbuild
GCLOUD_PROJECT_ID := $(GCLOUD_PROJECT_ID)
BUILD_ID := $(BUILD_ID)
TEST_ASSET_DIR := $(ROOTDIR)/_test
#----------------------------------------------------------------------------------
# Macros
#----------------------------------------------------------------------------------
# This macro takes a relative path as its only argument and returns all the files
# in the tree rooted at that directory that match the given criteria.
get_sources = $(shell find $(1) -name "*.go" | grep -v test | grep -v generated.go | grep -v mock_)
#----------------------------------------------------------------------------------
# Repo setup
#----------------------------------------------------------------------------------
# https://www.viget.com/articles/two-ways-to-share-git-hooks-with-your-team/
.PHONY: init
init:
git config core.hooksPath .githooks
.PHONY: fmt-changed
fmt-changed:
git diff --name-only | grep '.*.go$$' | xargs -- goimports -w
# must be a seperate target so that make waits for it to complete before moving on
.PHONY: mod-download
mod-download:
go mod download
.PHONY: update-deps
update-deps: mod-download
$(shell cd $(shell go list -f '{{ .Dir }}' -m github.com/solo-io/protoc-gen-ext); make install)
chmod +x $(shell go list -f '{{ .Dir }}' -m k8s.io/code-generator)/generate-groups.sh
GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports
GO111MODULE=off go get -u github.com/gogo/protobuf/gogoproto
GO111MODULE=off go get -u github.com/gogo/protobuf/protoc-gen-gogo
GO111MODULE=off go get -u github.com/cratonica/2goarray
GO111MODULE=off go get -v -u github.com/golang/mock/gomock
GO111MODULE=off go install github.com/golang/mock/mockgen
.PHONY: check-format
check-format:
NOT_FORMATTED=$$(gofmt -l ./projects/ ./pkg/ ./test/) && if [ -n "$$NOT_FORMATTED" ]; then echo These files are not formatted: $$NOT_FORMATTED; exit 1; fi
check-spelling:
./ci/spell.sh check
#----------------------------------------------------------------------------------
# Clean
#----------------------------------------------------------------------------------
# Important to clean before pushing new releases. Dockerfiles and binaries may not update properly
.PHONY: clean
clean:
rm -rf _output
rm -rf _test
rm -rf docs/site*
rm -rf docs/themes
rm -rf docs/resources
git clean -f -X install
# This is required to run if making changes to proto files then run `make generated-code -B`
clean-generated-code:
rm -rf projects/gloo/pkg/plugins/grpc/*.descriptor.go
#----------------------------------------------------------------------------------
# Generated Code and Docs
#----------------------------------------------------------------------------------
.PHONY: generated-code
generated-code: $(OUTPUT_DIR)/.generated-code verify-enterprise-protos update-licenses generate-helm-files
# Note: currently we generate CLI docs, but don't push them to the consolidated docs repo (gloo-docs). Instead, the
# Glooctl enterprise docs are pushed from the private repo.
# TODO(EItanya): make mockgen work for gloo
SUBDIRS:=$(shell ls -d -- */ | grep -v vendor)
$(OUTPUT_DIR)/.generated-code:
go mod tidy
find * -type f | grep .sk.md | xargs rm
GO111MODULE=on go generate ./...
rm docs/content/reference/cli/glooctl*; GO111MODULE=on go run projects/gloo/cli/cmd/docs/main.go
gofmt -w $(SUBDIRS)
goimports -w $(SUBDIRS)
mkdir -p $(OUTPUT_DIR)
touch $@
# Make sure that the enterprise API *.pb.go files that are generated but not used in this repo are valid.
.PHONY: verify-enterprise-protos
verify-enterprise-protos:
@echo Verifying validity of generated enterprise files...
$(GO_BUILD_FLAGS) GOOS=linux go build projects/gloo/pkg/api/v1/enterprise/verify.go
#----------------------------------------------------------------------------------
# Generate mocks
#----------------------------------------------------------------------------------
# The values in this array are used in a foreach loop to dynamically generate the
# commands in the generate-client-mocks target.
# For each value, the ":" character will be replaced with " " using the subst function,
# thus turning the string into a 3-element array. The n-th element of the array will
# then be selected via the word function
MOCK_RESOURCE_INFO := \
gloo:artifact:ArtifactClient \
gloo:endpoint:EndpointClient \
gloo:proxy:ProxyClient \
gloo:secret:SecretClient \
gloo:settings:SettingsClient \
gloo:upstream:UpstreamClient \
gateway:gateway:GatewayClient \
gateway:virtual_service:VirtualServiceClient\
gateway:route_table:RouteTableClient\
# Use gomock (https://github.com/golang/mock) to generate mocks for our resource clients.
.PHONY: generate-client-mocks
generate-client-mocks:
@$(foreach INFO, $(MOCK_RESOURCE_INFO), \
echo Generating mock for $(word 3,$(subst :, , $(INFO)))...; \
mockgen -destination=projects/$(word 1,$(subst :, , $(INFO)))/pkg/mocks/mock_$(word 2,$(subst :, , $(INFO)))_client.go \
-package=mocks \
github.com/solo-io/gloo/projects/$(word 1,$(subst :, , $(INFO)))/pkg/api/v1 \
$(word 3,$(subst :, , $(INFO))) \
;)
#----------------------------------------------------------------------------------
# glooctl
#----------------------------------------------------------------------------------
CLI_DIR=projects/gloo/cli
$(OUTPUT_DIR)/glooctl: $(SOURCES)
GO111MODULE=on go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/glooctl-linux-amd64: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/glooctl-darwin-amd64: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=darwin go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
$(OUTPUT_DIR)/glooctl-windows-amd64.exe: $(SOURCES)
$(GO_BUILD_FLAGS) GOOS=windows go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
.PHONY: glooctl
glooctl: $(OUTPUT_DIR)/glooctl
.PHONY: glooctl-linux-amd64
glooctl-linux-amd64: $(OUTPUT_DIR)/glooctl-linux-amd64
.PHONY: glooctl-darwin-amd64
glooctl-darwin-amd64: $(OUTPUT_DIR)/glooctl-darwin-amd64
.PHONY: glooctl-windows-amd64
glooctl-windows-amd64: $(OUTPUT_DIR)/glooctl-windows-amd64.exe
.PHONY: build-cli
build-cli: glooctl-linux-amd64 glooctl-darwin-amd64 glooctl-windows-amd64
#----------------------------------------------------------------------------------
# Gateway
#----------------------------------------------------------------------------------
GATEWAY_DIR=projects/gateway
GATEWAY_SOURCES=$(call get_sources,$(GATEWAY_DIR))
$(OUTPUT_DIR)/gateway-linux-amd64: $(GATEWAY_SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(GATEWAY_DIR)/cmd/main.go
.PHONY: gateway
gateway: $(OUTPUT_DIR)/gateway-linux-amd64
$(OUTPUT_DIR)/Dockerfile.gateway: $(GATEWAY_DIR)/cmd/Dockerfile
cp $< $@
gateway-docker: $(OUTPUT_DIR)/gateway-linux-amd64 $(OUTPUT_DIR)/Dockerfile.gateway
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.gateway \
-t $(IMAGE_REPO)/gateway:$(VERSION)
#----------------------------------------------------------------------------------
# Ingress
#----------------------------------------------------------------------------------
INGRESS_DIR=projects/ingress
INGRESS_SOURCES=$(call get_sources,$(INGRESS_DIR))
$(OUTPUT_DIR)/ingress-linux-amd64: $(INGRESS_SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(INGRESS_DIR)/cmd/main.go
.PHONY: ingress
ingress: $(OUTPUT_DIR)/ingress-linux-amd64
$(OUTPUT_DIR)/Dockerfile.ingress: $(INGRESS_DIR)/cmd/Dockerfile
cp $< $@
ingress-docker: $(OUTPUT_DIR)/ingress-linux-amd64 $(OUTPUT_DIR)/Dockerfile.ingress
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.ingress \
-t $(IMAGE_REPO)/ingress:$(VERSION)
#----------------------------------------------------------------------------------
# Access Logger
#----------------------------------------------------------------------------------
ACCESS_LOG_DIR=projects/accesslogger
ACCESS_LOG_SOURCES=$(call get_sources,$(ACCESS_LOG_DIR))
$(OUTPUT_DIR)/access-logger-linux-amd64: $(ACCESS_LOG_SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(ACCESS_LOG_DIR)/cmd/main.go
.PHONY: access-logger
access-logger: $(OUTPUT_DIR)/access-logger-linux-amd64
$(OUTPUT_DIR)/Dockerfile.access-logger: $(ACCESS_LOG_DIR)/cmd/Dockerfile
cp $< $@
access-logger-docker: $(OUTPUT_DIR)/access-logger-linux-amd64 $(OUTPUT_DIR)/Dockerfile.access-logger
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.access-logger \
-t $(IMAGE_REPO)/access-logger:$(VERSION)
#----------------------------------------------------------------------------------
# Discovery
#----------------------------------------------------------------------------------
DISCOVERY_DIR=projects/discovery
DISCOVERY_SOURCES=$(call get_sources,$(DISCOVERY_DIR))
$(OUTPUT_DIR)/discovery-linux-amd64: $(DISCOVERY_SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(DISCOVERY_DIR)/cmd/main.go
.PHONY: discovery
discovery: $(OUTPUT_DIR)/discovery-linux-amd64
$(OUTPUT_DIR)/Dockerfile.discovery: $(DISCOVERY_DIR)/cmd/Dockerfile
cp $< $@
discovery-docker: $(OUTPUT_DIR)/discovery-linux-amd64 $(OUTPUT_DIR)/Dockerfile.discovery
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.discovery \
-t $(IMAGE_REPO)/discovery:$(VERSION)
#----------------------------------------------------------------------------------
# Gloo
#----------------------------------------------------------------------------------
GLOO_DIR=projects/gloo
GLOO_SOURCES=$(call get_sources,$(GLOO_DIR))
$(OUTPUT_DIR)/gloo-linux-amd64: $(GLOO_SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(GLOO_DIR)/cmd/main.go
.PHONY: gloo
gloo: $(OUTPUT_DIR)/gloo-linux-amd64
$(OUTPUT_DIR)/Dockerfile.gloo: $(GLOO_DIR)/cmd/Dockerfile
cp hack/utils/oss_compliance/third_party_licenses.txt $(OUTPUT_DIR)/third_party_licenses.txt
cp $< $@
gloo-docker: $(OUTPUT_DIR)/gloo-linux-amd64 $(OUTPUT_DIR)/Dockerfile.gloo
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.gloo \
--build-arg ENVOY_IMAGE=$(ENVOY_GLOO_IMAGE) \
-t $(IMAGE_REPO)/gloo:$(VERSION)
#----------------------------------------------------------------------------------
# SDS Server - gRPC server for serving Secret Discovery Service config for Gloo MTLS
#----------------------------------------------------------------------------------
SDS_DIR=projects/sds/cmd
SDS_SOURCES=$(call get_sources,$(SDS_DIR))
$(OUTPUT_DIR)/sds-linux-amd64: $(SDS_SOURCES)
GO111MODULE=on CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(SDS_DIR)/main.go
.PHONY: sds
sds: $(OUTPUT_DIR)/sds-linux-amd64
$(OUTPUT_DIR)/Dockerfile.sds: $(SDS_DIR)/Dockerfile
cp $< $@
.PHONY: sds-docker
sds-docker: $(OUTPUT_DIR)/sds-linux-amd64 $(OUTPUT_DIR)/Dockerfile.sds
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.sds \
-t $(IMAGE_REPO)/sds:$(VERSION)
#----------------------------------------------------------------------------------
# Envoy init (BASE/SIDECAR)
#----------------------------------------------------------------------------------
ENVOYINIT_DIR=projects/envoyinit/cmd
ENVOYINIT_SOURCES=$(call get_sources,$(ENVOYINIT_DIR))
$(OUTPUT_DIR)/envoyinit-linux-amd64: $(ENVOYINIT_SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(ENVOYINIT_DIR)/main.go
.PHONY: envoyinit
envoyinit: $(OUTPUT_DIR)/envoyinit-linux-amd64
$(OUTPUT_DIR)/Dockerfile.envoyinit: $(ENVOYINIT_DIR)/Dockerfile.envoyinit
cp $< $@
$(OUTPUT_DIR)/docker-entrypoint.sh: $(ENVOYINIT_DIR)/docker-entrypoint.sh
cp $< $@
.PHONY: gloo-envoy-wrapper-docker
gloo-envoy-wrapper-docker: $(OUTPUT_DIR)/envoyinit-linux-amd64 $(OUTPUT_DIR)/Dockerfile.envoyinit $(OUTPUT_DIR)/docker-entrypoint.sh
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.envoyinit \
--build-arg ENVOY_IMAGE=$(ENVOY_GLOO_IMAGE) \
-t $(IMAGE_REPO)/gloo-envoy-wrapper:$(VERSION)
#----------------------------------------------------------------------------------
# Envoy init (WASM)
#----------------------------------------------------------------------------------
ENVOY_WASM_DIR=projects/envoyinit/cmd
ENVOY_WASM_SOURCES=$(call get_sources,$(ENVOY_WASM_DIR))
$(OUTPUT_DIR)/envoywasm-linux-amd64: $(ENVOY_WASM_SOURCES)
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(ENVOY_WASM_DIR)/main.go
.PHONY: envoywasm
envoywasm: $(OUTPUT_DIR)/envoywasm-linux-amd64
$(OUTPUT_DIR)/Dockerfile.envoywasm: $(ENVOY_WASM_DIR)/Dockerfile.envoywasm
cp $< $@
.PHONY: gloo-envoy-wasm-wrapper-docker
gloo-envoy-wasm-wrapper-docker: $(OUTPUT_DIR)/envoywasm-linux-amd64 $(OUTPUT_DIR)/Dockerfile.envoywasm
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.envoywasm \
-t $(IMAGE_REPO)/gloo-envoy-wasm-wrapper:$(VERSION)
#----------------------------------------------------------------------------------
# Certgen - Job for creating TLS Secrets in Kubernetes
#----------------------------------------------------------------------------------
CERTGEN_DIR=jobs/certgen/cmd
CERTGEN_SOURCES=$(call get_sources,$(CERTGEN_DIR))
$(OUTPUT_DIR)/certgen-linux-amd64: $(CERTGEN_SOURCES)
GO111MODULE=on CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CERTGEN_DIR)/main.go
.PHONY: certgen
certgen: $(OUTPUT_DIR)/certgen-linux-amd64
$(OUTPUT_DIR)/Dockerfile.certgen: $(CERTGEN_DIR)/Dockerfile
cp $< $@
.PHONY: certgen-docker
certgen-docker: $(OUTPUT_DIR)/certgen-linux-amd64 $(OUTPUT_DIR)/Dockerfile.certgen
docker build $(OUTPUT_DIR) -f $(OUTPUT_DIR)/Dockerfile.certgen \
-t $(IMAGE_REPO)/certgen:$(VERSION)
#----------------------------------------------------------------------------------
# Build All
#----------------------------------------------------------------------------------
.PHONY: build
build: gloo glooctl gateway discovery envoyinit certgen ingress
#----------------------------------------------------------------------------------
# Deployment Manifests / Helm
#----------------------------------------------------------------------------------
HELM_SYNC_DIR := $(OUTPUT_DIR)/helm
HELM_DIR := install/helm/gloo
# Creates Chart.yaml and values.yaml. See install/helm/README.md for more info.
.PHONY: generate-helm-files
generate-helm-files: $(OUTPUT_DIR)/.helm-prepared
HELM_PREPARED_INPUT := $(HELM_DIR)/generate.go $(wildcard $(HELM_DIR)/generate/*.go)
$(OUTPUT_DIR)/.helm-prepared: $(HELM_PREPARED_INPUT)
GO111MODULE=on go run $(HELM_DIR)/generate.go --version $(VERSION) --generate-helm-docs
touch $@
package-chart: generate-helm-files
mkdir -p $(HELM_SYNC_DIR)/charts
helm package --destination $(HELM_SYNC_DIR)/charts $(HELM_DIR)
helm repo index $(HELM_SYNC_DIR)
push-chart-to-registry: generate-helm-files
mkdir -p $(HELM_REPOSITORY_CACHE)
cp $(DOCKER_CONFIG)/config.json $(HELM_REPOSITORY_CACHE)/config.json
HELM_EXPERIMENTAL_OCI=1 helm chart save $(HELM_DIR) gcr.io/solo-public/gloo-helm:$(VERSION)
HELM_EXPERIMENTAL_OCI=1 helm chart push gcr.io/solo-public/gloo-helm:$(VERSION)
.PHONY: fetch-helm
fetch-helm:
mkdir -p './_output/helm'
gsutil -m rsync -r gs://solo-public-helm/ './_output/helm'
.PHONY: save-helm
save-helm:
ifeq ($(RELEASE),"true")
gsutil -m rsync -r './_output/helm' gs://solo-public-helm/
endif
#----------------------------------------------------------------------------------
# Build the Gloo Manifests that are published as release assets
#----------------------------------------------------------------------------------
.PHONY: render-manifests
render-manifests: install/gloo-gateway.yaml install/gloo-ingress.yaml install/gloo-knative.yaml
INSTALL_NAMESPACE ?= gloo-system
MANIFEST_OUTPUT = > /dev/null
ifneq ($(BUILD_ID),)
MANIFEST_OUTPUT =
endif
define HELM_VALUES
namespace:
create: true
crds:
create: true
endef
# Export as a shell variable, make variables do not play well with multiple lines
export HELM_VALUES
$(OUTPUT_DIR)/release-manifest-values.yaml:
@echo "$$HELM_VALUES" > $@
install/gloo-gateway.yaml: $(OUTPUT_DIR)/glooctl-linux-amd64 $(OUTPUT_DIR)/release-manifest-values.yaml package-chart
ifeq ($(RELEASE),"true")
$(OUTPUT_DIR)/glooctl-linux-amd64 install gateway -n $(INSTALL_NAMESPACE) -f $(HELM_SYNC_DIR)/charts/gloo-$(VERSION).tgz \
--values $(OUTPUT_DIR)/release-manifest-values.yaml --dry-run | tee $@ $(OUTPUT_YAML) $(MANIFEST_OUTPUT)
endif
install/gloo-knative.yaml: $(OUTPUT_DIR)/glooctl-linux-amd64 $(OUTPUT_DIR)/release-manifest-values.yaml package-chart
ifeq ($(RELEASE),"true")
$(OUTPUT_DIR)/glooctl-linux-amd64 install knative -n $(INSTALL_NAMESPACE) -f $(HELM_SYNC_DIR)/charts/gloo-$(VERSION).tgz \
--values $(OUTPUT_DIR)/release-manifest-values.yaml --dry-run | tee $@ $(OUTPUT_YAML) $(MANIFEST_OUTPUT)
endif
install/gloo-ingress.yaml: $(OUTPUT_DIR)/glooctl-linux-amd64 $(OUTPUT_DIR)/release-manifest-values.yaml package-chart
ifeq ($(RELEASE),"true")
$(OUTPUT_DIR)/glooctl-linux-amd64 install ingress -n $(INSTALL_NAMESPACE) -f $(HELM_SYNC_DIR)/charts/gloo-$(VERSION).tgz \
--values $(OUTPUT_DIR)/release-manifest-values.yaml --dry-run | tee $@ $(OUTPUT_YAML) $(MANIFEST_OUTPUT)
endif
#----------------------------------------------------------------------------------
# Release
#----------------------------------------------------------------------------------
GLOOE_CHANGELOGS_BUCKET=gloo-ee-changelogs
$(OUTPUT_DIR)/gloo-enterprise-version:
GO111MODULE=on go run hack/find_latest_enterprise_version.go
.PHONY: download-glooe-changelog
download-glooe-changelog: $(OUTPUT_DIR)/gloo-enterprise-version
mkdir -p '../solo-projects/changelog'
gsutil -m cp -r gs://$(GLOOE_CHANGELOGS_BUCKET)/$(shell cat $(OUTPUT_DIR)/gloo-enterprise-version)/* '../solo-projects/changelog'
# The code does the proper checking for a TAGGED_VERSION
.PHONY: upload-github-release-assets
upload-github-release-assets: print-git-info build-cli render-manifests
GO111MODULE=on go run ci/upload_github_release_assets.go $(ASSETS_ONLY_RELEASE)
.PHONY: publish-docs
publish-docs: generate-helm-files
cd docs && make docker-push-docs \
VERSION=$(VERSION) \
TAGGED_VERSION=$(TAGGED_VERSION) \
GCLOUD_PROJECT_ID=$(GCLOUD_PROJECT_ID) \
RELEASE=$(RELEASE) \
ON_DEFAULT_BRANCH=$(ON_DEFAULT_BRANCH)
#----------------------------------------------------------------------------------
# Docker
#----------------------------------------------------------------------------------
#
#---------
#--------- Push
#---------
DOCKER_IMAGES :=
ifeq ($(RELEASE),"true")
DOCKER_IMAGES := docker
endif
.PHONY: docker docker-push
docker: discovery-docker gateway-docker gloo-docker \
gloo-envoy-wrapper-docker gloo-envoy-wasm-wrapper-docker \
certgen-docker sds-docker ingress-docker access-logger-docker
# Depends on DOCKER_IMAGES, which is set to docker if RELEASE is "true", otherwise empty (making this a no-op).
# This prevents executing the dependent targets if RELEASE is not true, while still enabling `make docker`
# to be used for local testing.
# docker-push is intended to be run by CI
docker-push: $(DOCKER_IMAGES)
docker push $(IMAGE_REPO)/gateway:$(VERSION) && \
docker push $(IMAGE_REPO)/ingress:$(VERSION) && \
docker push $(IMAGE_REPO)/discovery:$(VERSION) && \
docker push $(IMAGE_REPO)/gloo:$(VERSION) && \
docker push $(IMAGE_REPO)/gloo-envoy-wrapper:$(VERSION) && \
docker push $(IMAGE_REPO)/gloo-envoy-wasm-wrapper:$(VERSION) && \
docker push $(IMAGE_REPO)/certgen:$(VERSION) && \
docker push $(IMAGE_REPO)/sds:$(VERSION) && \
docker push $(IMAGE_REPO)/access-logger:$(VERSION)
CLUSTER_NAME ?= kind
push-kind-images: docker
kind load docker-image $(IMAGE_REPO)/gateway:$(VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_REPO)/ingress:$(VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_REPO)/discovery:$(VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_REPO)/gloo:$(VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_REPO)/gloo-envoy-wrapper:$(VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_REPO)/gloo-envoy-wasm-wrapper:$(VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_REPO)/certgen:$(VERSION) --name $(CLUSTER_NAME)
kind load docker-image $(IMAGE_REPO)/access-logger:$(VERSION) --name $(CLUSTER_NAME)
#----------------------------------------------------------------------------------
# Build assets for Kube2e tests
#----------------------------------------------------------------------------------
#
# The following targets are used to generate the assets on which the kube2e tests rely upon. The following actions are performed:
#
# 1. Generate Gloo value files
# 2. Package the Gloo Helm chart to the _test directory (also generate an index file)
#
# The Kube2e tests will use the generated Gloo Chart to install Gloo to the GKE test cluster.
.PHONY: build-test-assets
build-test-assets: build-test-chart $(OUTPUT_DIR)/glooctl-linux-amd64 \
$(OUTPUT_DIR)/glooctl-darwin-amd64
.PHONY: build-kind-assets
build-kind-assets: push-kind-images build-kind-chart $(OUTPUT_DIR)/glooctl-linux-amd64 \
$(OUTPUT_DIR)/glooctl-darwin-amd64
.PHONY: build-test-chart
build-test-chart:
mkdir -p $(TEST_ASSET_DIR)
GO111MODULE=on go run $(HELM_DIR)/generate.go --version $(VERSION)
helm package --destination $(TEST_ASSET_DIR) $(HELM_DIR)
helm repo index $(TEST_ASSET_DIR)
.PHONY: build-kind-chart
build-kind-chart:
rm -rf $(TEST_ASSET_DIR)
mkdir -p $(TEST_ASSET_DIR)
GO111MODULE=on go run $(HELM_DIR)/generate.go --version $(VERSION)
helm package --destination $(TEST_ASSET_DIR) $(HELM_DIR)
helm repo index $(TEST_ASSET_DIR)
#----------------------------------------------------------------------------------
# Third Party License Management
#----------------------------------------------------------------------------------
.PHONY: update-licenses
update-licenses:
# TODO(helm3): fix after we completely drop toml parsing in favor of go modules
# cd hack/utils/oss_compliance && GO111MODULE=on go run main.go
#----------------------------------------------------------------------------------
# Printing makefile variables utility
#----------------------------------------------------------------------------------
# use `make print-MAKEFILE_VAR` to print the value of MAKEFILE_VAR
print-% : ; @echo $($*)