-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
82 lines (61 loc) · 2.48 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
export KUBECONFIG=config/cluster.yaml
sha1 := $(shell git rev-parse --short=8 HEAD)
geth := /bin/geth --datadir=/data
net ?= testnet
cfg := config/$(net)
region := us-central1
zone := us-central1-a
all: deploy
build:
gcloud container builds submit \
-t gcr.io/hanzo-ai/geth:$(sha1) \
-t gcr.io/hanzo-ai/geth:latest \
geth
deploy: build
kubectl set image deployment/geth-$(net) geth-$(net)=gcr.io/hanzo-ai/geth:$(sha1)
create: build create-volume create-pod
# Setup a high-performance persistent disk. Use SSDs, and at least 500 GB of storage for adequate IO performance
# Ensure proper flags for ext4:
# mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
# create-disk:
# gcloud compute disks create --size=500GB --type=pd-ssd --zone=us-central1-a geth-$(net)-data
create-volume:
kubectl apply -f config/sc.yaml
kubectl apply -f $(cfg)/pvc.yaml
create-pod:
kubectl apply -f $(cfg)/pod.yaml
create-snapshot:
gcloud compute disks snapshot $(disk) --snapshot-names=$(snapshot) --zone=$(zone)
create-disk-from-snapshot:
gcloud compute disks create $(disk) --source-snapshot=$(snapshot) --type=pd-ssd --zone=$(zone)
delete-pod:
kubectl delete -f $(cfg)/pod.yaml
delete:
kubectl delete -f $(cfg)/pod.yaml || echo not running
kubectl delete -f $(cfg)/pvc.yaml || echo not running
kubectl delete -f $(cfg)/sc.yaml || echo not running
gcloud compute disks delete --zone=$(zone) geth-$(net)-disk
status:
kubectl get pods -o yaml
logs:
kubectl logs geth-$(net) -f
ssh:
kubectl exec -it geth-$(net) -- /bin/bash
attach:
kubectl exec -it geth-$(net) -- $(geth) attach
nodeinfo:
kubectl exec -it geth-$(net) -- $(geth) attach --exec 'admin.nodeInfo'
syncstatus:
kubectl exec -it geth-$(net) -- $(geth) attach --exec 'eth.syncing'
# Add secret for hanzo-ai gcr.io. This enables our cluster to pull images from
# our shared image repo. This should only be run once after cluster creation.
add-gcr-key:
kubectl create -f config/secret.yaml
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gcr-secret"}]}'
# Get credentials for kubectl for current cluster
get-credentials:
gcloud container clusters get-credentials ethereum --zone $(zone) --project hanzo-ai
# Default to whatever zone you launched your cluster in to reduce key strokes
region-zone-defaults:
gcloud compute project-info add-metadata --metadata=google-compute-default-region=$(region)
gcloud compute project-info add-metadata --metadata=google-compute-default-zone=$(zone)