-
Notifications
You must be signed in to change notification settings - Fork 1
/
validator.tmpl.yaml
158 lines (157 loc) · 4.65 KB
/
validator.tmpl.yaml
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
apiVersion: v1
kind: Pod
metadata:
name: val-[validator_index]
namespace: localnet
labels:
app: libra-validator
libra-node: "true"
role: 'validator'
annotations:
prometheus.io/should_be_scraped: 'true'
prometheus.io/scrape: 'true'
prometheus.io/port: '9101'
spec:
hostNetwork: true
nodeName: "bbchain[node_index]"
initContainers:
- name: init
image: pariwesh/thesis:libra_init-2.0.0
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /opt/libra/data
name: data-[validator_index]
securityContext:
runAsUser: 0 # To get permissions to write to /opt/libra/data
command:
- "bash"
- "-c"
- |
set -x;
# clear data when initiating first validator
# if [ "0" == "[validator_index]" ]; then
# fi
rm -rf /opt/libra/data/*
CFG_SEED_PEER_IP=$(kubectl get pod/val-0 -o=jsonpath='{.status.podIP}');
NUM_VALIDATORS=[number_of_validators];
while [ -z "$CFG_SEED_PEER_IP" ]; do
sleep 5;
CFG_SEED_PEER_IP=$(kubectl get pod/val-0 -o=jsonpath='{.status.podIP}');
echo "Waiting for pod/val-0 IP Address";
done;
echo -n "$CFG_SEED_PEER_IP" > /opt/libra/data/seed_peer_ip
# check number of validators befor proceeding to next step
until [ $(kubectl get pods -l app=libra-validator | grep ^val | grep -e Init -e Running | wc -l) = "$NUM_VALIDATORS" ]; do
sleep 30;
echo "Waiting for all validator pods to be scheduled";
done
containers:
- name: main
image: pariwesh/thesis:libra_validator_dynamic-2.0.1
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 10m
ports:
- containerPort: 6180
- containerPort: 6181
- containerPort: 9101
- containerPort: 6191
- containerPort: 8080
- containerPort: 8000
- containerPort: 9102
volumeMounts:
- mountPath: /opt/libra/data
name: data-[validator_index]
securityContext:
runAsUser: 0 # To get permissions to write to /opt/libra/data
env:
- name: CFG_OVERRIDES
value: "enabled=true"
- name: CFG_NODE_INDEX
value: "[validator_index]"
- name: CFG_NUM_VALIDATORS
value: "[number_of_validators]"
- name: CFG_NUM_FULLNODES
value: "0"
- name: CFG_SEED
value: "1337133713371337133713371337133713371337133713371337133713371337"
- name: CFG_FULLNODE_SEED
value: ""
- name: RUST_LOG
value: "info"
- name: STRUCT_LOG_FILE
value: "/opt/libra/data/events.log"
- name: STRUCT_LOG_LEVEL
value: "debug"
- name: RUST_BACKTRACE
value: "1"
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
command:
- "bash"
- "-c"
- |
set -x;
export CFG_LISTEN_ADDR=$MY_POD_IP;
export CFG_SEED_PEER_IP=$(cat /opt/libra/data/seed_peer_ip);
#apt-get update && apt-get install vim -y
# if [ "$CFG_LISTEN_ADDR" == "$CFG_SEED_PEER_IP" ]; then
# echo "I am validator 0";
# else
# until [ "3" = "$NUM_VALIDATORS" ]; do
# sleep 30;
# echo "sleeping";
# done
# fi
exec bash /docker-run-dynamic.sh
- name: safety-rules
image: pariwesh/thesis:libra_safety_rules-2.0.0
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /opt/libra/data
name: data-[validator_index]
securityContext:
runAsUser: 0 # To get permissions to write to /opt/libra/data
env:
- name: CFG_NODE_INDEX
value: "[validator_index]"
- name: CFG_NUM_VALIDATORS
value: "[number_of_validators]"
- name: CFG_SEED
value: "1337133713371337133713371337133713371337133713371337133713371337"
- name: CFG_SAFETY_RULES_LISTEN_ADDR
value: "127.0.0.1:6185"
- name: PUSH_METRICS_ENDPOINT
value: "http://[prometheus_pushgateway]:9091/metrics/job/safety_rules/role/validator/peer_id/val-[validator_index]"
- name: "CFG_OVERRIDES"
value: 'path="/opt/libra/data/common/safety_rules.toml"'
- name: RUST_LOG
value: "info"
command:
- "bash"
- "-c"
- |
set -x;
exec bash /docker-run-dynamic.sh
volumes:
- name: data-[validator_index]
emptyDir: {}
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: minikube
operator: Exists
topologyKey: "kubernetes.io/hostname"
terminationGracePeriodSeconds: 5
tolerations:
- key: "validators"
operator: "Exists"
effect: "NoSchedule"
- key: "node.kubernetes.io/not-ready"
operator: "Exists"
effect: "NoSchedule"