Use PostgREST instead of pgAdmin

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-09-13 11:47:20 -07:00
parent c4a5caa587
commit 3910efe3ab

View File

@ -35,7 +35,7 @@ metadata:
spec: spec:
type: LoadBalancer type: LoadBalancer
selector: selector:
app: pgadmin app: postgrest
ports: ports:
- name: web - name: web
protocol: TCP protocol: TCP
@ -144,94 +144,34 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
namespace: ${ZED_KUBE_NAMESPACE} namespace: ${ZED_KUBE_NAMESPACE}
name: pgadmin name: postgrest
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app: pgadmin app: postgrest
template: template:
metadata: metadata:
labels: labels:
app: pgadmin app: postgrest
spec: spec:
securityContext:
runAsUser: 0
containers: containers:
- name: pgadmin - name: postgrest
image: "dpage/pgadmin4" image: "postgrest/postgrest"
ports: ports:
- containerPort: 8080 - containerPort: 8080
protocol: TCP protocol: TCP
livenessProbe:
httpGet:
path: /misc/ping
port: 8080
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /misc/ping
port: 8080
initialDelaySeconds: 1
periodSeconds: 1
command: ['/bin/sh', '-c']
args:
- |
set -e
mkdir -p /var/lib/pgadmin/storage/max_zed.dev
python3 - <<EOF
import os
import json
from urllib.parse import urlparse;
url = urlparse(os.environ["ZED_DATABASE_URL"])
db = url.path[1:]
with open("/pgadmin4/servers.json", "w") as f:
f.write(json.dumps({
"Servers": {
"1": {
"Name": "Zed Database",
"Group": "Server Group 1",
"Port": url.port,
"Username": url.username,
"Host": url.hostname,
"SSLMode": "require",
"PassFile": "/passfile",
"MaintenanceDB": db,
}
}
}))
with open("/var/lib/pgadmin/storage/max_zed.dev/passfile", "w") as f:
f.write(f"*:*:*:*:{url.password}")
os.chmod("/var/lib/pgadmin/storage/max_zed.dev/passfile", 0o600)
EOF
exec /entrypoint.sh
env: env:
- name: PGADMIN_LISTEN_PORT - name: PGRST_SERVER_PORT
value: "8080" value: "8080"
- name: ZED_DATABASE_URL - name: PGRST_DB_URI
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: database name: database
key: url key: url
- name: PGADMIN_CONFIG_WTF_CSRF_CHECK_DEFAULT - name: PGRST_JWT_SECRET
value: "False"
- name: PGADMIN_DEFAULT_EMAIL
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: pgadmin name: postgrest
key: email key: jwt_secret
- name: PGADMIN_DEFAULT_PASSWORD
valueFrom:
secretKeyRef:
name: pgadmin
key: password