-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidator.yaml
More file actions
219 lines (210 loc) · 7 KB
/
validator.yaml
File metadata and controls
219 lines (210 loc) · 7 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
apiVersion: v1
kind: Service
metadata:
name: persistencecore-validator
labels:
app.kubernetes.io/name: persistencecore-validator
spec:
clusterIP: None
ports:
- name: p2p
port: 26656
protocol: TCP
targetPort: 26656
- name: rpc
port: 26657
protocol: TCP
targetPort: 26657
- name: http
port: 8081
protocol: TCP
targetPort: 8081
selector:
app.kubernetes.io/name: persistencecore-validator
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: persistencecore-validator
spec:
serviceName: persistencecore-validator
replicas: 0
revisionHistoryLimit: 3
selector:
matchLabels:
app.kubernetes.io/instance: persistencecore
app.kubernetes.io/name: persistencecore-validator
template:
metadata:
annotations:
quality: release
role: api-gateway
sla: high
tier: gateway
labels:
app.kubernetes.io/instance: persistencecore
app.kubernetes.io/type: persistencecore-validator
app.kubernetes.io/name: persistencecore-validator
app.kubernetes.io/version: '0.1'
spec:
initContainers:
- name: wait-for-genesis
image:persistenceone/persistencecore:v12-alliance-rc0
imagePullPolicy: Always
env:
- name: GENESIS_HOST
value: persistencecore-genesis.dev-core.svc.cluster.local
- name: GENESIS_PORT
value: "8081"
command:
- bash
- "-c"
- |
while [ $(curl -sw '%{http_code}' http://$GENESIS_HOST:$GENESIS_PORT/node_id -o /dev/null) -ne 200 ]; do
echo "Genesis validator does not seem to be ready. Waiting for it to start..."
sleep 10;
done
echo "Ready to start"
exit 0
- name: init-validator
image:persistenceone/persistencecore:v12-alliance-rc0
imagePullPolicy: Always
env:
- name: CHAIN_ID
valueFrom:
configMapKeyRef:
key: chain.id
name: persistencecore
- name: HOME_DIR
value: /persistencecore
- name: GENESIS_HOST
value: persistencecore-genesis.dev-core.svc.cluster.local
- name: GENESIS_PORT
value: "8081"
command:
- bash
- "-c"
- |
VAL_INDEX=${HOSTNAME##*-}
echo "Validator Index: $VAL_INDEX"
VAL_NAME=$(jq -r ".validators[$VAL_INDEX].name" /configs/validators.json)
echo "Validator Index: $VAL_INDEX, Key name: $VAL_NAME"
echo "Printing genesis file before init"
ls -lrht $HOME_DIR/config
jq -r ".validators[$VAL_INDEX].mnemonic" /configs/validators.json | persistenceCore init $VAL_NAME --chain-id $CHAIN_ID --home $HOME_DIR --recover
jq -r ".validators[$VAL_INDEX].mnemonic" /configs/validators.json | persistenceCore keys add $VAL_NAME --recover --keyring-backend="test" --home $HOME_DIR
curl http://$GENESIS_HOST:$GENESIS_PORT/genesis -o $HOME_DIR/config/genesis.json
echo "Genesis file that we got....."
cat $HOME_DIR/config/genesis.json
echo "All exports"
export
echo "Fetching genesis file"
GENESIS_NODE_P2P=$(curl -s http://$GENESIS_HOST:$GENESIS_PORT/node_id)@$GENESIS_HOST:26656
echo "Node P2P: $GENESIS_NODE_P2P"
sed -i "s/persistent_peers = \"\"/persistent_peers = \"$GENESIS_NODE_P2P\"/g" $HOME_DIR/config/config.toml
sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' $HOME_DIR/config/config.toml
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $HOME_DIR/config/config.toml
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $HOME_DIR/config/config.toml
sed -i 's/index_all_keys = false/index_all_keys = true/g' $HOME_DIR/config/config.toml
echo "Printing the whole config.toml file"
cat $HOME_DIR/config/config.toml
curl -s http://$GENESIS_HOST:$GENESIS_PORT/pub_key
resources:
limits:
cpu: "0.2"
memory: "200M"
requests:
cpu: "0.1"
memory: "200M"
volumeMounts:
- mountPath: /persistencecore
name: validator-pv-storage
- mountPath: /configs
name: addresses
containers:
- name: validator
image: persistenceone/persistencecore
imagePullPolicy: Always
env:
- name: CHAIN_ID
valueFrom:
configMapKeyRef:
key: chain.id
name: persistencecore
- name: HOME_DIR
value: /persistencecore
- name: GENESIS_HOST
value: persistencecore-genesis.dev-core
- name: GENESIS_RPC_PORT
value: "26657"
command:
- bash
- "-c"
- |
# Starting the chain
persistenceCore start --home $HOME_DIR
lifecycle:
postStart:
exec:
command:
- bash
- "-c"
- |
bash /scripts/create-staking-tx.sh > "/create-staking-tx.log"
resources:
limits:
cpu: "1"
memory: "1G"
requests:
cpu: "0.5"
memory: "500M"
volumeMounts:
# - mountPath: /persistencecore
# name: persistencecore
- mountPath: /persistencecore
name: validator-pv-storage
- mountPath: /configs
name: addresses
- mountPath: /scripts
name: scripts
- name: exposer-app
image: persistenceone/exposer:latest
imagePullPolicy: Always
env:
- name: HOME_DIR
value: /persistencecore
- name: GENESIS_FILE
value: /persistencecore/config/genesis.json
- name: PORT
value: "8081"
- name: CLIENT_NAME
value: "persistencecore"
command: [ "exposer" ]
resources:
limits:
cpu: "0.1"
memory: "100M"
requests:
cpu: "0.1"
memory: "100M"
volumeMounts:
- mountPath: /persistencecore
name: validator-pv-storage
volumes:
- name: addresses
configMap:
name: test-addresses-persistencecore
- name: scripts
configMap:
name: scripts
volumeClaimTemplates:
- metadata:
name: validator-pv-storage
spec:
storageClassName: do-block-storage
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 5Gi
---