Add db command. Update Tiltfile / app to store DB host in secrets

This commit is contained in:
Luke Van Seters 2021-10-13 14:55:53 -04:00
parent 0ddb0104af
commit 2e921f2685
3 changed files with 26 additions and 4 deletions

View File

@ -16,6 +16,7 @@ k8s_yaml(configmap_from_dict("mev-inspect-rpc", inputs = {
k8s_yaml(secret_from_dict("mev-inspect-db-credentials", inputs = {
"username" : "postgres",
"password": "password",
"host": "postgresql",
}))
docker_build_with_restart("mev-inspect-py", ".",

View File

@ -19,6 +19,11 @@ spec:
image: mev-inspect-py
command: [ "/app/entrypoint.sh" ]
env:
- name: POSTGRES_HOST
valueFrom:
secretKeyRef:
name: mev-inspect-db-credentials
key: host
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
@ -29,8 +34,6 @@ spec:
secretKeyRef:
name: mev-inspect-db-credentials
key: password
- name: POSTGRES_HOST
value: postgresql
- name: RPC_URL
valueFrom:
configMapKeyRef:

22
mev
View File

@ -2,9 +2,27 @@
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
backfill)
echo "Running backfill from block $2 to block $3"
db)
echo "Connecting to $DB_NAME"
db
;;
inspect)
block_number=$2