Search
ctrl+/
Ask AI
ctrl+.
Light
Dark
System
Sign in

Deploying Gel to Google Cloud​

In this guide we show how to deploy Gel on GCP using Cloud SQL and Kubernetes.

Gel Cloud: Reset the default password for the admin role

If you want to dump an existing Gel Cloud instance and restore it to a new self-managed instance, you need to change the automatically generated password for the default admin role - edgedb or admin. The administrator role name and its password used in the dump/restore process must be the same in both the instance dumped from and the instance restored to for the Gel tooling to continue functioning properly. To change the default password in the Cloud instance, execute the following query in the instance:

Copy
ALTER ROLE admin { set password := 'new_password' };

Make sure you are logged into Google Cloud.

Copy
$ 
gcloud init

Set the PROJECT environment variable to the project name you'd like to use. Google Cloud only allow letters, numbers, and hyphens.

Copy
$ 
PROJECT=gel

Then create a project with this name. Skip this step if your project already exists.

Copy
$ 
gcloud projects create $PROJECT

Then enable the requisite APIs.

Copy
$ 
  
  
  
  
gcloud services enable \
  container.googleapis.com \
  sqladmin.googleapis.com \
  iam.googleapis.com \
  --project=$PROJECT

Use the read command to securely assign a value to the PASSWORD environment variable.

Copy
$ 
echo -n "> " && read -s PASSWORD

Then create a Cloud SQL instance and set the password.

Copy
$ 
  
  
  
  
  
  
gcloud sql instances create ${PROJECT}-postgres \
  --database-version=POSTGRES_17 \
  --edition=enterprise \
  --cpu=1 \
  --memory=3840MiB \
  --region=us-west2 \
  --project=$PROJECT
Copy
$ 
  
  
  
gcloud sql users set-password postgres \
  --instance=${PROJECT}-postgres \
  --password=$PASSWORD \
  --project=$PROJECT

Create an empty Kubernetes cluster inside your project.

Copy
$ 
  
  
  
gcloud container clusters create ${PROJECT}-k8s \
  --zone=us-west2-a \
  --num-nodes=1 \
  --project=$PROJECT

Create a new service account, configure its permissions, and generate a credentials.json file.

Copy
$ 
  
gcloud iam service-accounts create ${PROJECT}-account \
  --project=$PROJECT
Copy
$ 
MEMBER="${PROJECT}-account@${PROJECT}.iam.gserviceaccount.com"
Copy
$ 
  
  
  
gcloud projects add-iam-policy-binding $PROJECT \
  --member=serviceAccount:${MEMBER} \
  --role=roles/cloudsql.admin \
  --project=$PROJECT
Copy
$ 
  
gcloud iam service-accounts keys create credentials.json \
  --iam-account=${MEMBER}

Then use this credentials.json to authenticate the Kubernetes CLI tool kubectl.

Copy
$ 
gcloud components install gke-gcloud-auth-plugin
Copy
$ 
  
kubectl create secret generic cloudsql-instance-credentials \
  --from-file=credentials.json=credentials.json
Copy
$ 
  
  
  
  
INSTANCE_CONNECTION_NAME=$(
  gcloud sql instances describe ${PROJECT}-postgres \
      --format="value(connectionName)" \
      --project=$PROJECT
)
Copy
$ 
DSN="postgresql://postgres:${PASSWORD}@127.0.0.1:5432"
Copy
$ 
  
  
  
kubectl create secret generic cloudsql-db-credentials \
  --from-literal=dsn=$DSN \
  --from-literal=password=$PASSWORD \
  --from-literal=instance=${INSTANCE_CONNECTION_NAME}=tcp:5432

Download the starter Gel Kubernetes configuration file. This file specifies a persistent volume, a container running a Cloud SQL authorization proxy, and a container to run Gel itself. It relies on the secrets we declared in the previous step.

Copy
$ 
wget "https://raw.githubusercontent.com\
/geldata/gel-deploy/dev/gcp/deployment.yaml"
Copy
$ 
kubectl apply -f deployment.yaml

Ensure the pods are running.

Copy
$ 
kubectl get pods
NAME                     READY   STATUS              RESTARTS   AGE
gel-977b8fdf6-jswlw      0/2     ContainerCreating   0          16s

The READY 0/2 tells us neither of the two pods have finished booting. Re-run the command until 2/2 pods are READY.

If there were errors you can check Gel's logs with:

Copy
$ 
kubectl logs deployment/gel --container gel

Now that our Gel instance is up and running, we need to download a local copy of its self-signed TLS certificate (which it generated on startup) and pass it as a secret into Kubernetes. Then we'll redeploy the pods.

Copy
$ 
  
  
  
  
  
  
  
  
kubectl create secret generic cloudsql-tls-credentials \
  --from-literal=tlskey="$(
      kubectl exec deploy/gel -c=gel -- \
          gel-show-secrets.sh --format=raw GEL_SERVER_TLS_KEY
  )" \
  --from-literal=tlscert="$(
      kubectl exec deploy/gel -c=gel -- \
          gel-show-secrets.sh --format=raw GEL_SERVER_TLS_CERT
  )"
Copy
$ 
kubectl delete -f deployment.yaml
Copy
$ 
kubectl apply -f deployment.yaml
Copy
$ 
kubectl expose deploy/gel --type LoadBalancer

To connect your application to the Gel instance, you'll need to provide connection parameters. Gel client libraries can be configured using either a DSN (connection string) or individual environment variables.

Your connection requires the following components:

  • Host: The EXTERNAL-IP of the LoadBalancer service

  • Port: 5656 (the default Gel port)

  • Username: admin (the default superuser)

  • Password: The value you assigned to $PASSWORD

  • Branch: main (the default branch)

Get the public-facing IP address of your database:

Copy
$ 
kubectl get service
NAME         TYPE           CLUSTER-IP  EXTERNAL-IP   PORT(S)
gel          LoadBalancer   <ip>        <ip>          5656:30841/TCP

Copy the EXTERNAL-IP associated with the gel service and construct your instance's DSN:

Copy
$ 
GEL_IP=<copy IP address here>
Copy
$ 
GEL_DSN="gel://admin:${PASSWORD}@${GEL_IP}"

To print the final DSN, you can echo it. Note that you should only run this command on a computer you trust, like a personal laptop or sandboxed environment.

Copy
$ 
echo $GEL_DSN

Since we configured Gel with a self-signed TLS certificate, your application needs the certificate to connect securely. Retrieve it from the running pod:

Copy
$ 
  
  
kubectl exec deploy/gel -c=gel -- \
  gel-show-secrets.sh --format=raw GEL_SERVER_TLS_CERT \
  > gel-tls-cert.pem

Alternatively, retrieve it using the Gel CLI:

Copy
$ 
  
gel --dsn $GEL_DSN --tls-security insecure \
  query "SELECT sys::get_tls_certificate()" > gel-tls-cert.pem

Test your connection by opening a REPL:

Copy
$ 
gel --dsn $GEL_DSN --tls-security insecure
Gel x.x (repl x.x)
Type \help for help, \quit to quit.
gel> select "hello world!";

To make your remote instance easier to work with during local development, create an alias using gel instance link.

The command groups gel instance and gel project are not intended to manage production instances.

Copy
$ 
  
  
  
  
  
echo $PASSWORD | gel instance link \
  --dsn $GEL_DSN \
  --password-from-stdin \
  --non-interactive \
  --trust-tls-cert \
  my_gcp_instance

You can now refer to the remote instance using the alias my_gcp_instance. Use this alias wherever an instance name is expected:

Copy
$ 
gel -I my_gcp_instance
Gel x.x
Type \help for help, \quit to quit.
gel>

Or apply migrations:

Copy
$ 
gel -I my_gcp_instance migrate

Set these environment variables where you deploy your application:

Copy
GEL_DSN="gel://admin:<password>@<external-ip>:5656"
# For self-signed certificates, provide the CA cert:
GEL_TLS_CA_FILE="/path/to/gel-tls-cert.pem"
# Or embed the certificate content directly:
GEL_TLS_CA="<certificate content>"
# Or (for development only) disable TLS verification:
# GEL_CLIENT_TLS_SECURITY=insecure

Gel's client libraries will automatically read these environment variables.

Using an HTTP client, you can perform health checks to monitor the status of your Gel instance. Learn how to use them with our health checks guide.