-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsteps.sh
More file actions
66 lines (45 loc) · 2.24 KB
/
steps.sh
File metadata and controls
66 lines (45 loc) · 2.24 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
export PROJECT_ID=stately-vector-311213
gcloud config set project stately-vector-311213
cd manager & docker build -t gcr.io/${PROJECT_ID}/manager:latest .
cd ../worker & docker ^Cild -t gcr.io/${PROJECT_ID}/worker:latest .
cd ..
# upload to container registery so GKE can download them
gcloud services enable containerregistry.googleapis.com
# if project unset -> gcloud config set project stately-vector-311213
gcloud auth configure-docker
docker push gcr.io/${PROJECT_ID}/manager:latest
docker push gcr.io/${PROJECT_ID}/worker:latest
# If GKE cluster not setup -> https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app#creating_a_cluster
# if you already have a GKE cluster running -> gcloud container clusters get-credentials my-first-cluster-1 --zone us-central1-c --project stately-vector-311213
kubectl get nodes
# if no deployment conf file -> https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app#deploying_the_sample_app_to
kubectl apply -f k8s/manager.yaml
kubectl apply -f k8s/worker.yaml
kubectl get pods
kubectl get service
# Get the EXTERNAL-IP from above for test.
curl EXTERNAL-IP
python3 call.py
# for logs
kubectl logs svc/dias-manager-svc
kubectl logs svc/dias-worker-svc
# Auto scale
kubectl autoscale deployment dias-worker --cpu-percent=70 --min=1 --max=10
# Check autoscale status
kubectl get hpa
## Scaling based on custom and multiple metrics (like requests per second) can be done
## https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
# delete services
kubectl delete service dias-manager-svc dias-worker-svc
# delete images
gcloud container images delete gcr.io/${PROJECT_ID}/manager:latest --force-delete-tags --quiet
gcloud container images delete gcr.io/${PROJECT_ID}/worker:latest --force-delete-tags --quiet
# Delete cluster
# https://kubernetes.io/docs/reference/kubectl/cheatsheet/
##############################################
Testing google functions
# Manager
gcloud functions call func-manager --data '{"Input": "test", "Category": "NLP", "Task": "fakenews"}'
# Worker
# gcloud functions call function-test --data '{"Input": "test", "Category": "NLP", "Tag": "fakenews", "Model": 1}'
# Passed as params not json.