docs/docs/enterprise/getting-started/quickstart-google-cloud-run.mdx
import LatestRelease from '@site/src/components/LatestRelease'; import ProductBadge from '@site/src/components/ProductBadge';
This tutorial will help you run Hasura Enterprise Edition as a Google Cloud Run service using the gcloud CLI.
This guide requires HGE versions v2.12.0 and above. Installation instructions are below.
This tutorial assumes that the following prerequisites have been met:
gcloud CLI is installed and configured. For more information about installing or upgrading
your gcloud CLI, see Installing the gcloud CLI.gcloud user has the
required permissions to deploy a
cloud run service.The install manifests repo contains all installation manifests required to deploy Hasura anywhere. Get the Cloud Run env vars file from there:
wget https://raw.githubusercontent.com/hasura/graphql-engine/main/install-manifests/enterprise/google-cloud-run/env.yaml
Edit env.yaml and set the right values:
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_REDIS_URL: 'redis://redis:6379'
HASURA_GRAPHQL_RATE_LIMIT_REDIS_URL: 'redis://redis:6379'
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
Examples of HASURA_GRAPHQL_METADATA_DATABASE_URL:
postgres://admin:password@db-ip:5432/my_dbpostgres://admin:@db-ip:5432/my_db (if there is no password)Examples of HASURA_GRAPHQL_REDIS_URL and HASURA_GRAPHQL_RATE_LIMIT_REDIS_URL:
redis://admin:password@redis-ip:6379redis://redis-ip:6379 (if there is no password):::info Note
If your password contains special characters (e.g. #, %, $, @, etc.), you need to URL encode them in the
HASURA_GRAPHQL_METADATA_DATABASE_URL env var (e.g. %40 for @).
The Hasura GraphQL Engine needs access permissions on your Postgres database as described in Postgres permissions.
The HASURA_GRAPHQL_ADMIN_SECRET should never be passed from the client to the Hasura GraphQL Engine as it would give
the client full admin rights to your Hasura instance. See Authentication & Authorization for
information on setting up authentication.
Convert confidential environment variables such as Postgres / Redis URLs, admin / metrics secrets to fetch them from secrets, see here for more information.
:::
If you don't have a license key, you can skip this step and proceed with this guide to set up Hasura. Once you have Hasura up and running, you can sign up for a free 30 day Enterprise Edition trial from the Hasura console.
If you have been provided a license key by the Hasura team, add it as an environment variable to Hasura. Edit env.yaml to set the license key as the value for the HASURA_GRAPHQL_EE_LICENSE_KEY environment variable.
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_REDIS_URL: 'redis://redis:6379'
HASURA_GRAPHQL_RATE_LIMIT_REDIS_URL: 'redis://redis:6379'
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
HASURA_GRAPHQL_EE_LICENSE_KEY: '<license key>'
Cloud Run does not allow using images from Dockerhub. Due to this limitation it's necessary to pull the Hasura graphql-engine image from Dockerhub and push it to your container registry, see here for more information.
This can be done using the below steps:
<pre> <code> VERSION= <LatestRelease /> docker pull hasura/graphql-engine:$VERSION docker tag hasura/graphql-engine:$VERSION gcr.io/<MY_PROJECT_ID>/hasura/graphql-engine:$VERSION docker push gcr.io/<MY_PROJECT_ID>/hasura/graphql-engine:$VERSION </code> </pre>Update the image and vpc connector values in the below commmand.
gcloud run deploy hasura \
--image=gcr.io/<MY_PROJECT_ID>/hasura/graphql-engine:tag \
--env-vars-file=env.yaml \
--vpc-connector=<vpc-connector-name> \
--allow-unauthenticated \
--min-instances=1 \
--cpu=1 \
--memory=2048Mi \
--port=8080
Wait for the deployment to finish. Upon successful completion, a success message is displayed along with the URL of the deployed service.
Click the displayed URL link to open the unique and stable endpoint of the Hasura service.