This repository was archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-node.sh
More file actions
executable file
·69 lines (55 loc) · 1.85 KB
/
deploy-node.sh
File metadata and controls
executable file
·69 lines (55 loc) · 1.85 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
#!/bin/bash
if [ "$1" = "" ]
then
echo "Usage: $0 <node name>"
exit
fi
set -o pipefail
NAMESPACE=$1
NODE_NAME=$1
# download node config from gcp bucket
gcloud storage cp gs://charon-nodes-config/${NODE_NAME}/${NODE_NAME}.env .
# override the env vars
OLDIFS=$IFS
IFS='
'
export $(< ./${NODE_NAME}.env)
IFS=$OLDIFS
# delete node env vars file
rm ./${NODE_NAME}.env
# create the namespace
nsStatus=`kubectl get namespace ${NAMESPACE} --no-headers --output=go-template={{.metadata.name}} 2>/dev/null`
if [ -z "$nsStatus" ]; then
echo "Namespace (${NAMESPACE}) not found, creating a new one."
kubectl create namespace ${NAMESPACE} --dry-run=client -o yaml | kubectl apply -f -
fi
# download node config
mkdir -p ./.charon/
gcloud storage cp -r gs://charon-nodes-config/${NODE_NAME} ./.charon/
# set current namespace
kubectl config set-context --current --namespace=${NAMESPACE}
# create validators keys k8s secrets
files=""
for secret in ./.charon/${NODE_NAME}/validator_keys/*; do
files="$files --from-file=./.charon/${NODE_NAME}/validator_keys/$(basename $secret)"
done
kubectl -n $NAMESPACE create secret generic validator-keys $files --dry-run=client -o yaml | kubectl apply -f -
kubectl -n $NAMESPACE create secret generic private-key --from-file=private-key=./.charon/${NODE_NAME}/charon-enr-private-key --dry-run=client -o yaml | kubectl apply -f -
kubectl -n $NAMESPACE create secret generic cluster-lock --from-file=cluster-lock.json=./.charon/${NODE_NAME}/cluster-lock.json --dry-run=client -o yaml | kubectl apply -f -
# deploy charon node
eval "cat <<EOF
$(<./templates/charon.yaml)
EOF
" | kubectl apply -f -
# deploy teku vc
eval "cat <<EOF
$(<./templates/teku.yaml)
EOF
" | kubectl apply -f -
# deploy prometheus agent
eval "cat <<EOF
$(<./templates/prometheus.yaml)
EOF
" | kubectl apply -f -
# delete node config before exit
rm -rf ./.charon/${NODE_NAME}