-
Notifications
You must be signed in to change notification settings - Fork 593
/
Makefile
102 lines (89 loc) · 3.93 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
# Copyright 2019 Google LLC
#
# 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
#
# https://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.
.-PHONY: cluster deploy deploy-continuous logs checkstyle check-env
CLUSTER=bank-of-anthos
E2E_PATH=${PWD}/.github/workflows/ui-tests/
cluster: check-env
gcloud container clusters create ${CLUSTER} \
--project=${PROJECT_ID} --zone=${ZONE} \
--machine-type=e2-standard-4 --num-nodes=4 \
--enable-stackdriver-kubernetes --subnetwork=default \
--labels csm=
deploy: check-env
echo ${CLUSTER}
gcloud container clusters get-credentials --project ${PROJECT_ID} ${CLUSTER} --zone ${ZONE}
skaffold run --default-repo=us-central1-docker.pkg.dev/${PROJECT_ID}/bank-of-anthos -l skaffold.dev/run-id=${CLUSTER}-${PROJECT_ID}-${ZONE}
deploy-continuous: check-env
gcloud container clusters get-credentials --project ${PROJECT_ID} ${CLUSTER} --zone ${ZONE}
skaffold dev --default-repo=us-central1-docker.pkg.dev/${PROJECT_ID}/bank-of-anthos
monolith-fw-rule: check-env
export CLUSTER_POD_CIDR="$(shell gcloud container clusters describe ${CLUSTER} --format="value(clusterIpv4Cidr)" --project ${PROJECT_ID} --zone=${ZONE})" && \
gcloud compute firewall-rules create monolith-gke-cluster --allow=TCP:8080 --project=${PROJECT_ID} --source-ranges=$${CLUSTER_POD_CIDR} --target-tags=monolith
monolith: check-env
ifndef GCS_BUCKET
# GCS_BUCKET is undefined
# ATTENTION: Deployment proceeding with canonical pre-built monolith artifacts
endif
# build and deploy Bank of Anthos along with a monolith backend service
mvn -f src/ledgermonolith/ package
src/ledgermonolith/scripts/build-artifacts.sh
src/ledgermonolith/scripts/deploy-monolith.sh
sed -i 's/\[PROJECT_ID\]/${PROJECT_ID}/g' src/ledgermonolith/config.yaml
gcloud container clusters get-credentials --project ${PROJECT_ID} ${CLUSTER} --zone ${ZONE}
kubectl apply -f src/ledgermonolith/config.yaml
kubectl apply -f extras/jwt/jwt-secret.yaml
kubectl apply -f kubernetes-manifests/accounts-db.yaml
kubectl apply -f kubernetes-manifests/userservice.yaml
kubectl apply -f kubernetes-manifests/contacts.yaml
kubectl apply -f kubernetes-manifests/frontend.yaml
kubectl apply -f kubernetes-manifests/loadgenerator.yaml
monolith-build: check-env
ifndef GCS_BUCKET
$(error GCS_BUCKET is undefined; specify a Google Cloud Storage bucket to store your build artifacts)
endif
# build the artifacts for the ledgermonolith service
mvn -f src/ledgermonolith/ package
src/ledgermonolith/scripts/build-artifacts.sh
monolith-deploy: check-env
ifndef GCS_BUCKET
# GCS_BUCKET is undefined
# ATTENTION: Deployment proceeding with canonical pre-built monolith artifacts
endif
# deploy the ledgermonolith service to a GCE VM
src/ledgermonolith/scripts/deploy-monolith.sh
checkstyle:
mvn checkstyle:check
# disable warnings: import loading, todos, function members, duplicate code, public methods
pylint --rcfile=./.pylintrc ./src/*/*.py
test-e2e:
E2E_URL="http://$(shell kubectl get service frontend -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" && \
docker run -it -v ${E2E_PATH}:/e2e -w /e2e -e CYPRESS_baseUrl=$${E2E_URL} cypress/included:5.0.0 $(E2E_FLAGS)
test-unit:
mvn test
for SERVICE in "contacts" "userservice"; \
do \
pushd src/$$SERVICE;\
python3 -m venv $$HOME/venv-$$SERVICE; \
source $$HOME/venv-$$SERVICE/bin/activate; \
pip install -r requirements.txt; \
python -m pytest -v -p no:warnings; \
deactivate; \
popd; \
done
check-env:
ifndef PROJECT_ID
$(error PROJECT_ID is undefined)
else ifndef ZONE
$(error ZONE is undefined)
endif