Use PostgREST instead of pgAdmin

Max Brunsfeld and Mikayla created

Co-authored-by: Mikayla <mikayla@zed.dev>

Change summary

crates/collab/k8s/manifest.template.yml | 82 +++-----------------------
1 file changed, 11 insertions(+), 71 deletions(-)

Detailed changes

crates/collab/k8s/manifest.template.yml 🔗

@@ -35,7 +35,7 @@ metadata:
 spec:
   type: LoadBalancer
   selector:
-    app: pgadmin
+    app: postgrest
   ports:
     - name: web
       protocol: TCP
@@ -144,94 +144,34 @@ apiVersion: apps/v1
 kind: Deployment
 metadata:
   namespace: ${ZED_KUBE_NAMESPACE}
-  name: pgadmin
+  name: postgrest
 
 spec:
   replicas: 1
   selector:
     matchLabels:
-      app: pgadmin
+      app: postgrest
   template:
     metadata:
       labels:
-        app: pgadmin
+        app: postgrest
     spec:
-      securityContext:
-        runAsUser: 0
       containers:
-        - name: pgadmin
-          image: "dpage/pgadmin4"
+        - name: postgrest
+          image: "postgrest/postgrest"
           ports:
             - containerPort: 8080
               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:
-            - name: PGADMIN_LISTEN_PORT
+            - name: PGRST_SERVER_PORT
               value: "8080"
-            - name: ZED_DATABASE_URL
+            - name: PGRST_DB_URI
               valueFrom:
                 secretKeyRef:
                   name: database
                   key: url
-            - name: PGADMIN_CONFIG_WTF_CSRF_CHECK_DEFAULT
-              value: "False"
-            - name: PGADMIN_DEFAULT_EMAIL
-              valueFrom:
-                secretKeyRef:
-                  name: pgadmin
-                  key: email
-            - name: PGADMIN_DEFAULT_PASSWORD
+            - name: PGRST_JWT_SECRET
               valueFrom:
                 secretKeyRef:
-                  name: pgadmin
-                  key: password
+                  name: postgrest
+                  key: jwt_secret