-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
99 lines (82 loc) · 3.02 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
# Copyright 2019 VMware, Inc.
# SPDX-License-Identifier: BSD-3-Clause
SHELL := /bin/bash
.PHONY: help
help:
@echo "Usage: make <TARGET>"
@echo ""
@echo "Available targets are:"
@echo ""
@echo " generate-go Generate Go files from proto"
@echo " generate-js Generate JavaScript files from proto"
@echo ""
@echo " run-server Run the server"
@echo " run-server-docker Run the server over Docker"
@echo " run-client-local Run the client and connect to local server"
@echo " run-client-istio Run the client and connect to server via Istio"
@echo ""
@echo " build-server Build the server image"
@echo " build-web-ui Build the web-ui image"
@echo ""
@echo " deploy-server Deploy the server over Kubernetes"
@echo " deploy-web-ui Deploy the web-ui over Kubernetes"
@echo " deploy-gateway Deploy the gateway configuration"
@echo " watch-pods Watch the Kubernetes deployment"
@echo ""
@echo " inspect-proxy Inspect the Istio proxy configuration"
@echo " proxy-logs Inspect the Istio proxy logs"
@echo ""
@echo " reset Reset the deployment"
@echo ""
.PHONY: generate-go
generate-go:
protoc -I proto/ proto/emoji.proto \
--go_out=plugins=grpc:proto
.PHONY: generate-js
generate-js:
protoc -I proto/ proto/emoji.proto \
--js_out=import_style=commonjs:proto \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:proto
.PHONY: run-server
run-server:
go run -v cmd/server.go
.PHONY: run-server-docker
run-server-docker:
docker run --rm -p 9000:9000 vnoronha/grpc-web-istio-demo:server
.PHONY: run-client-local
run-client-local:
go run -v cmd/client.go --server 'localhost:9000' --text 'I like :pizza: and :sushi:!'
.PHONY: run-client-istio
run-client-istio:
go run -v cmd/client.go --server '192.168.99.100:31380' --text 'I like :pizza: and :sushi:!'
.PHONY: build-server
build-server:
docker build -f docker/server.Dockerfile -t vnoronha/grpc-web-istio-demo:server .
.PHONY: build-web-ui
build-web-ui:
docker build -f docker/web-ui.Dockerfile -t vnoronha/grpc-web-istio-demo:web-ui .
.PHONY: deploy-server
deploy-server:
kubectl apply -f <(istioctl kube-inject -f istio/server.yaml)
.PHONY: deploy-web-ui
deploy-web-ui:
kubectl apply -f <(istioctl kube-inject -f istio/web-ui.yaml)
.PHONY: deploy-gateway
deploy-gateway:
kubectl apply -f istio/gateway.yaml
.PHONY: watch-pods
watch-pods:
watch kubectl get pods
.PHONY: inspect-proxy
inspect-proxy:
$(eval POD := $(shell kubectl get pod -l app=server -o jsonpath='{.items..metadata.name}'))
istioctl proxy-config listeners ${POD}.default --port 9000 -o json
.PHONY: proxy-logs
proxy-logs:
$(eval POD := $(shell kubectl get pod -l app=server -o jsonpath='{.items..metadata.name}'))
kubectl logs ${POD} istio-proxy -f
.PHONY: reset
reset:
kubectl delete -f istio/server.yaml
kubectl delete -f istio/web-ui.yaml
kubectl delete -f istio/gateway.yaml