Add db command. Update Tiltfile / app to store DB host in secrets
This commit is contained in:
parent
0ddb0104af
commit
2e921f2685
1
Tiltfile
1
Tiltfile
@ -16,6 +16,7 @@ k8s_yaml(configmap_from_dict("mev-inspect-rpc", inputs = {
|
|||||||
k8s_yaml(secret_from_dict("mev-inspect-db-credentials", inputs = {
|
k8s_yaml(secret_from_dict("mev-inspect-db-credentials", inputs = {
|
||||||
"username" : "postgres",
|
"username" : "postgres",
|
||||||
"password": "password",
|
"password": "password",
|
||||||
|
"host": "postgresql",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
docker_build_with_restart("mev-inspect-py", ".",
|
docker_build_with_restart("mev-inspect-py", ".",
|
||||||
|
@ -19,6 +19,11 @@ spec:
|
|||||||
image: mev-inspect-py
|
image: mev-inspect-py
|
||||||
command: [ "/app/entrypoint.sh" ]
|
command: [ "/app/entrypoint.sh" ]
|
||||||
env:
|
env:
|
||||||
|
- name: POSTGRES_HOST
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: mev-inspect-db-credentials
|
||||||
|
key: host
|
||||||
- name: POSTGRES_USER
|
- name: POSTGRES_USER
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
@ -29,8 +34,6 @@ spec:
|
|||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: mev-inspect-db-credentials
|
name: mev-inspect-db-credentials
|
||||||
key: password
|
key: password
|
||||||
- name: POSTGRES_HOST
|
|
||||||
value: postgresql
|
|
||||||
- name: RPC_URL
|
- name: RPC_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
configMapKeyRef:
|
||||||
|
22
mev
22
mev
@ -2,9 +2,27 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
DB_NAME=mev_inspect
|
||||||
|
|
||||||
|
function get_kube_db_secret(){
|
||||||
|
kubectl get secrets mev-inspect-db-credentials -o jsonpath="{.data.$1}" | base64 --decode
|
||||||
|
}
|
||||||
|
|
||||||
|
function db(){
|
||||||
|
host=$(get_kube_db_secret "host")
|
||||||
|
username=$(get_kube_db_secret "username")
|
||||||
|
password=$(get_kube_db_secret "password")
|
||||||
|
|
||||||
|
kubectl run -i --rm --tty postgres-client \
|
||||||
|
--env="PGPASSWORD=$password" \
|
||||||
|
--image=jbergknoff/postgresql-client \
|
||||||
|
-- $DB_NAME --host=$host --user=$username
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
backfill)
|
db)
|
||||||
echo "Running backfill from block $2 to block $3"
|
echo "Connecting to $DB_NAME"
|
||||||
|
db
|
||||||
;;
|
;;
|
||||||
inspect)
|
inspect)
|
||||||
block_number=$2
|
block_number=$2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user