-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
182 lines (151 loc) · 6.49 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
SHELL=/bin/bash
THIS_MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
THIS_MKFILE_DIR := $(dir $(THIS_MKFILE_PATH))
include $(THIS_MKFILE_DIR)common/Makefile
include $(THIS_MKFILE_DIR)common/Makefile.gke
GCP_PROJECT_ID ?= $(shell gcloud config list --format 'value(core.project)')
GKE_BASE_MACHINE_TYPE ?= e2-standard-2
CLUSTER_NAME=kong-gateway-4-istio-mesh
CLUSTER_ZONE=us-central1-a
CURRENT_WORKING_DIR=$(shell pwd)
WHO_AM_I=$(shell whoami)
TIMESTAMP=$(shell date)
pad=$(printf '%0.1s' "-"{1..80})
KONG_MESH_VERSION ?= 2.4.1
KUMA_VERSION ?= 2.4.1
KONG_NAMESPACE ?= kong
KONG_HELM_RELEASE ?= kong
DEMO_NAMESPACE ?= mesh4devs
LICENSE_PATH ?= ~/tmp/istio+kong
define print-prompt =
printf "\e[96m➜ \e[0m"
endef
define print-header =
printf "\n%-50s\n" $1 | tr ' ~' '- '
endef
.DEFAULT_GOAL := help
minikube-create-cluster:
@$(call print-header,"creating new minikube cluster")
@$(call print-prompt)
minikube start --cpus 6 --memory 8Gb
@echo ""
minikube-destroy-cluster:
@$(call print-header,"deleting minikube cluster")
@$(call print-prompt)
minikube delete --all
@echo ""
minikube-use-context:
@$(call print-header,"switching to minikube context...")
@$(call print-prompt)
kubectl config use-context minikube
@echo ""
kong-mesh-install:
@echo "☸️ Installing Kuma 🐻❄️"
if [ -d "./kong-mesh-${KONG_MESH_VERSION}" ]; then \
echo "Found ./kong-mesh-${KONG_MESH_VERSION}"; \
install -m 755 ./kong-mesh-${KONG_MESH_VERSION}/bin/kumactl ~/bin/kumactl ;\
else \
echo "No Kong Mesh installation found"; \
echo "☸️ Downloading 🦍 Kong Mesh 𐄳 ..." ;\
curl -L https://docs.konghq.com/mesh/installer.sh | sh - ;\
fi
@echo "${BLUE}𐄳${RESET} 🐻❄️ using kumactl..."
which kumactl
@echo "${BLUE}𐄳${RESET} Installing Kuma Control Plane..."
kumactl install control-plane --license-path ${LICENSE_PATH}/license.json | kubectl apply -f -
@echo ""
kuma-install:
@echo "☸️ Installing Kuma 🐻❄️"
if [ -d "./kuma-${KUMA_VERSION}" ]; then \
echo "Found ./kuma-${KUMA_VERSION}"; \
install -m 755 ./kuma-${KUMA_VERSION}/bin/kumactl ~/bin/kumactl ;\
else \
echo "No kuma installation found"; \
echo "☸️ Downloading 🐻❄️ Kuma 𐄳 ..." ;\
curl -L https://kuma.io/installer.sh | VERSION=${KUMA_VERSION} sh - ;\
install -m 755 ./kuma-${KUMA_VERSION}/bin/kumactl ~/bin/kumactl ;\
fi
@echo "${BLUE}𐄳${RESET} 🐻❄️ using kumactl..."
which kumactl
@echo "${BLUE}𐄳${RESET} Installing Kuma Control Plane..."
kubectl config current-context
kumactl install control-plane | kubectl apply -f -
@echo ""
kuma-uninstall: check-dependencies
@echo "Uninstalling Kuma CP"
kumactl install control-plane | kubectl delete -f -
@echo ""
mesh-validate: check-dependencies
kubectl get pods -n kuma-system
kumactl inspect meshes
kong-mesh-cp-ui-pf: check-dependencies
kubectl port-forward svc/kong-mesh-control-plane -n kong-mesh-system 5681:5681 &
kuma-cp-ui-pf: check-dependencies
kubectl port-forward svc/kuma-control-plane -n kuma-system 5681:5681 &
kong-mesh-observability-ui: check-dependencies
kubectl port-forward svc/grafana -n mesh-observability 3000:3000
kong-mesh-policy: check-dependencies
kubectl apply -f ./mesh/mesh.yaml
#kubectl apply -k ./mesh
kong-gateway-install: check-dependencies
@echo "☸️ Installing Kong 🦍 to ${GREEN}${KONG_NAMESPACE}${RESET} namespace..."
kubectl create namespace ${KONG_NAMESPACE}
kubectl label namespace ${KONG_NAMESPACE} kuma.io/sidecar-injection=enabled
helm repo add kong https://charts.konghq.com && helm repo update
helm install -n ${KONG_NAMESPACE} ${KONG_HELM_RELEASE} kong/kong
kubectl -n ${KONG_NAMESPACE} wait --for=condition=Available deployment ${KONG_HELM_RELEASE}-kong
@echo ""
kong-gateway-uninstall: check-dependencies
@echo "☸️ Uninstalling Kong from ${GREEN}${KONG_NAMESPACE}${RESET} namespace..."
helm uninstall -n ${KONG_NAMESPACE} ${KONG_HELM_RELEASE}
kubectl delete namespace ${KONG_NAMESPACE}
@echo ""
obs-tools-install: check-dependencies
@echo "☸️ Installing Observability Tools - Prometheus 🔥, Grafana 📊, Jaeger, Loki"
kumactl install observability | kubectl apply -f -
@echo ""
obs-tools-uninstall: check-dependencies
@echo "❌ Uninstalling Observability Tools"
kumactl install observability | kubectl delete -f -
@echo ""
skaffold-run:
@$(call check-dependency,skaffold)
@echo "☕️ Deploy Apps with Skaffold"
skaffold run -n mesh4java
@echo ""
skaffold-delete: check-dependencies
@$(call check-dependency,skaffold)
@echo "🔥 uninstall Apps with "
skaffold delete -n mesh4java
@echo ""
demo-apps-install: check-dependencies
@echo "👩💻 Installing meeting and work apps with Kustomize"
kubectl create namespace ${DEMO_NAMESPACE}
kubectl label namespace mesh4devs kuma.io/sidecar-injection=enabled
kubectl apply -k ./kubernetes -n ${DEMO_NAMESPACE}
kubectl -n ${DEMO_NAMESPACE} wait --for=condition=Available deployment work
@echo ""
demo-apps-uninstall: check-dependencies
@echo "🔥 removing meeting and work apps"
kubectl delete -k ./kubernetes -n ${DEMO_NAMESPACE}
kubectl delete namespace ${DEMO_NAMESPACE}
@echo ""
help:
@echo ""
@echo " ${BLUE}:: ${GREEN}Kuma 🐻❄️ Service Mesh${RESET} for ☕️ Java Developers ${BLUE}::${RESET}"
@echo ""
@echo "The demo setup demonstrates how to use Kong Gateway and Kong Ingress Controller with Istio Service Mesh"
@echo ""
@echo "${BLUE}Targets${RESET} (in order to execute:)"
@echo "${BLUE}------ minikube targets -----------------------------------------------------${RESET}"
@echo " | ${BLUE}minikube-create-cluster${RESET}: create local minikube cluster"
@echo " | ${BLUE}minikube-delete-cluster${RESET}: destroy local minikube cluster"
@echo " | ${BLUE}minikube-use-context${RESET}: use minikube context as kubectl api endpoint"
@echo "${BLUE}------ kuma targets -----------------------------------------------------${RESET}"
@echo " | ${BLUE}kuma-install${RESET}: download and install Kuma, kumactl, Kuma Controll Plane"
@echo " | ${BLUE}mesh-validate${RESET}: validate installation of Kuma CP"
@echo "${BLUE}------ apps targets -----------------------------------------------------${RESET}"
@echo " | ${BLUE}skaffold-run${RESET}: deploy apps"
@echo " | ${BLUE}skaffold-delete${RESET}: undeploy apps"
@echo "${BLUE}-----------------------------------------------------------------------------${RESET}"
@echo "If something doesn't work, report at https://github.com/gAmUssA/kuma4java/issues"