docs: restructure deployment section (#5339)

This commit is contained in:
Marion Schleifer 2020-07-23 14:34:17 +02:00 committed by GitHub
parent 2eab6a89aa
commit d4972feb55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 931 additions and 981 deletions

View File

@ -12,6 +12,9 @@ Hasura GraphQL engine on Azure with Container Instances and Postgres
:depth: 1
:local:
Introduction
------------
This guide talks about how to deploy the Hasura GraphQL engine on `Azure
<https://azure.microsoft.com>`__ using `Container Instances
<https://azure.microsoft.com/en-us/services/container-instances/>`__ with `Azure
@ -222,6 +225,8 @@ Hasura is able to connect to the database.
If you're using an existing/external database, make sure the firewall rules for
the database allow connection for Azure services.
.. _azure_logs:
Checking logs
^^^^^^^^^^^^^

View File

@ -12,16 +12,19 @@ Hasura GraphQL engine One-click App on DigitalOcean Marketplace
:depth: 1
:local:
Introduction
------------
The Hasura GraphQL engine is available as a One-click app on the DigitalOcean
Marketplace. It is packed with a `Postgres <https://www.postgresql.org/>`__
database and `Caddy <https://caddyserver.com/>`__ webserver for easy and
automatic HTTPS using `Let's Encrypt <https://letsencrypt.org/>`__.
Quickstart
----------
Deploying Hasura on Digital Ocean
---------------------------------
1. Create a Hasura One-click Droplet
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step 1: Create a Hasura One-click Droplet
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Click the button below to create a new Hasura GraphQL engine Droplet through
the DigitalOcean Marketplace. For first time users, the link also contains a
@ -34,8 +37,8 @@ support most workloads. (``Ctrl+Click`` to open in a new tab)
:class: no-shadow
:target: https://marketplace.digitalocean.com/apps/hasura?action=deploy&refcode=c4d9092d2c48&utm_source=hasura&utm_campaign=docs
2. Open console
~~~~~~~~~~~~~~~
Step 2: Open console
^^^^^^^^^^^^^^^^^^^^
Once the Hasura GraphQL engine Droplet is ready, you can visit the Droplet IP to
open the Hasura console, where you can create tables, explore GraphQL APIs etc.
@ -62,8 +65,8 @@ can create a table on this Postgres instance and make your first GraphQL query.
:class: no-shadow
:alt: Hasura console
3. Create a table
~~~~~~~~~~~~~~~~~
Step 3: Create a table
^^^^^^^^^^^^^^^^^^^^^^
Navigate to ``Data -> Create table`` on the console and create a table called ``profile`` with the following columns:
@ -82,8 +85,8 @@ Choose ``id`` as the Primary key and click the ``Create`` button.
:class: no-shadow
:alt: Hasura console - create table
4. Insert sample data
~~~~~~~~~~~~~~~~~~~~~
Step 4: Insert sample data
^^^^^^^^^^^^^^^^^^^^^^^^^^
Once the table is created, go to the ``Insert Row`` tab and insert some sample rows:
@ -99,8 +102,8 @@ Once the table is created, go to the ``Insert Row`` tab and insert some sample r
:class: no-shadow
:alt: Hasura console - insert data
5. Try out GraphQL
~~~~~~~~~~~~~~~~~~
Step 5: Try out GraphQL
^^^^^^^^^^^^^^^^^^^^^^^
Switch to the ``GraphiQL`` tab on top and execute the following GraphQL query:
@ -117,8 +120,10 @@ Switch to the ``GraphiQL`` tab on top and execute the following GraphQL query:
:class: no-shadow
:alt: Hasura console - GraphiQL
Secure the GraphQL endpoint
---------------------------
.. _digital_ocean_secure:
Securing the GraphQL endpoint
-----------------------------
By default Hasura is exposed without any admin secret. Anyone can read and write
to your database using GraphQL. When deploying to production, you should secure
@ -127,41 +132,46 @@ tables.
To add an admin secret key, follow the steps described below:
1. Connect to the Droplet via SSH:
Step 1: Connect to the Droplet via SSH
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
ssh root@<your_droplet_ip>
ssh root@<your_droplet_ip>
2. Go to the ``/etc/hasura`` directory:
Step 2: Go to the ``/etc/hasura`` directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
cd /etc/hasura
cd /etc/hasura
3. Edit ``docker-compose.yaml`` and un-comment the line that mentions admin secret key.
Also change it to some unique secret:
Step 3: Set an admin secret
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
Edit ``docker-compose.yaml`` and un-comment the line that mentions admin secret key.
Also change it to some unique secret:
vim docker-compose.yaml
.. code-block:: bash
...
# un-comment next line to add an admin secret key
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
...
vim docker-compose.yaml
# type ESC followed by :wq to save and quit
...
# un-comment next line to add an admin secret key
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
...
# type ESC followed by :wq to save and quit
4. Update the container:
Step 4: Update the container
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
docker-compose up -d
.. code-block:: bash
docker-compose up -d
That's it. Visit the console at ``http://<your_droplet_ip>/console`` and it should
prompt for the admin secret key. Further API requests can be made by adding the
@ -179,47 +189,57 @@ If you own a domain, you can enable HTTPS on this Droplet by mapping the domain
to the Droplet's IP. The Hasura GraphQL Droplet is configured with Caddy which is an
HTTP/2 web server with automatic HTTPS using Let's Encrypt.
1. Go to your domain's DNS dashboard and add an A record mapping the domain to the Droplet IP.
2. Connect to the Droplet via SSH:
Step 1: Add a record mapping
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
Go to your domain's DNS dashboard and add an A record mapping the domain to the Droplet IP.
ssh root@<your_droplet_ip>
Step 2: Connect to the Droplet via SSH
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
ssh root@<your_droplet_ip>
3. Go to the ``/etc/hasura`` directory:
Step 3: Go to the ``/etc/hasura`` directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
cd /etc/hasura
cd /etc/hasura
4. Edit the ``Caddyfile`` and change ``:80`` to your domain:
Step 4: Edit the ``Caddyfile`` and change ``:80`` to your domain
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
vim Caddyfile
vim Caddyfile
...
add_your-domain-here {
proxy / graphql-engine:8080 {
websocket
}
...
add_your-domain-here {
proxy / graphql-engine:8080 {
websocket
}
...
}
...
# type ESC followed by :wq to save and quit
# type ESC followed by :wq to save and quit
5. Restart the container:
Step 5: Restart the container
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
docker-compose restart caddy
docker-compose restart caddy
Go to ``https://<your_domain>/console`` to visit the Hasura console.
.. _do_updating:
Updating to the latest version
------------------------------
@ -228,74 +248,87 @@ changing the version tag in ``docker-compose.yaml``. You can find the latest
releases on the `GitHub releases page
<https://github.com/hasura/graphql-engine/releases>`__.
1. Connect to the Droplet via SSH:
Step 1: Connect to the Droplet via SSH
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
ssh root@<your_droplet_ip>
ssh root@<your_droplet_ip>
2. Go to the ``/etc/hasura`` directory:
Step 2: Go to the ``/etc/hasura`` directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
cd /etc/hasura
cd /etc/hasura
3. Edit ``docker-compose.yaml`` and change the image tag to the latest one:
Step 3: Edit ``docker-compose.yaml`` and change the image tag to the latest one
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
vim docker-compose.yaml
vim docker-compose.yaml
...
graphql-engine:
image: hasura/graphql-engine:latest_tag_here
...
...
graphql-engine:
image: hasura/graphql-engine:latest_tag_here
...
# type ESC followed by :wq to save and quit
# type ESC followed by :wq to save and quit
4. Restart the container:
Step 4: Restart the container
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
docker-compose up -d
docker-compose up -d
Using DigitalOcean Managed Postgres Database
--------------------------------------------
1. Create a new Postgres Database from the DigitalOcean Console, preferably in the
same region as the Droplet.
2. Once the database is created, under the "Overview" tab, from the "Connection
Details" section, choose "Connection string" from the dropdown.
3. "Connection string" is the "Database URL". Copy it.
4. Connect to the Droplet via SSH:
Step 1: Create a Postgres database
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
Create a new Postgres database from the DigitalOcean console, preferably in the same region as the Droplet.
ssh root@<your_droplet_ip>
Step 2: Get the database URL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once the database is created, under the "Overview" tab, from the "Connection Details" section, choose "Connection string" from the dropdown.
"Connection string" is the "Database URL". Copy it.
Step 3: Connect to the Droplet via SSH
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
ssh root@<your_droplet_ip>
5. Go to the ``/etc/hasura`` directory:
Step 4: Go to the ``/etc/hasura`` directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
cd /etc/hasura
cd /etc/hasura
6. Edit ``docker-compose.yaml`` and change the database URL:
Step 5: Edit ``docker-compose.yaml`` and change the database URL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
vim docker-compose.yaml
vim docker-compose.yaml
...
# change the url to use a different database
HASURA_GRAPHQL_DATABASE_URL: <database-url>
...
...
# change the url to use a different database
HASURA_GRAPHQL_DATABASE_URL: <database-url>
...
# type ESC followed by :wq to save and quit
# type ESC followed by :wq to save and quit
Similarly, the database URL can be changed to connect to any other Postgres
database.
@ -319,29 +352,34 @@ If you need to configure the pool size or the timeout, you can use the below env
If you still want to enable connection pooling on your managed database on DigitalOcean, you should do so in the ``session`` mode.
.. _do_logs:
Logs
----
Step 1: Connect to the Droplet via SSH
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. Connect to the Droplet via SSH:
.. code-block:: bash
.. code-block:: bash
ssh root@<your_droplet_ip>
ssh root@<your_droplet_ip>
2. Go to the ``/etc/hasura`` directory:
Step 2: Go to the ``/etc/hasura`` directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
.. code-block:: bash
cd /etc/hasura
cd /etc/hasura
3. To checks logs for any container, use the following command:
Step 3: Check logs
^^^^^^^^^^^^^^^^^^
.. code-block:: bash
To checks logs for any container, use the following command:
docker-compose logs <container_name>
.. code-block:: bash
docker-compose logs <container_name>
Where ``<container_name>`` is one of ``graphql-engine``, ``postgres`` or
``caddy``.

View File

@ -12,17 +12,23 @@ Run Hasura GraphQL engine using Docker
:depth: 1
:local:
Introduction
------------
This guide assumes that you already have Postgres running and helps you set up the Hasura GraphQL engine using Docker
and connect it to your Postgres database.
Deploying Hasura using Docker
-----------------------------
Prerequisites
-------------
^^^^^^^^^^^^^
- `Docker <https://docs.docker.com/install/>`_
Step 1: Get the **docker-run.sh** bash script
---------------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The `hasura/graphql-engine/install-manifests <https://github.com/hasura/graphql-engine/tree/stable/install-manifests>`_
repo contains all installation manifests required to deploy Hasura anywhere.
@ -34,7 +40,7 @@ Get the Docker run bash script from there:
$ wget https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/docker-run/docker-run.sh
Step 2: Configure the **docker-run.sh** script
----------------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``docker-run.sh`` script has a sample Docker run command in it. The following changes have to be
made to the command:
@ -43,7 +49,7 @@ made to the command:
- Network config
Database URL
^^^^^^^^^^^^
************
Edit the ``HASURA_GRAPHQL_DATABASE_URL`` env var value, so that you can connect to your Postgres instance.
@ -73,7 +79,7 @@ Examples of ``HASURA_GRAPHQL_DATABASE_URL``:
:ref:`Postgres permissions <postgres_permissions>`.
Network config
^^^^^^^^^^^^^^
**************
If your Postgres instance is running on ``localhost``, the following changes will be needed to the ``docker run``
command to allow the Docker container to access the host's network:
@ -125,7 +131,7 @@ command to allow the Docker container to access the host's network:
Step 3: Run the Hasura Docker container
---------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Execute ``docker-run.sh`` & check if everything is running well:
@ -138,27 +144,112 @@ Execute ``docker-run.sh`` & check if everything is running well:
097f58433a2b hasura/graphql-engine.. ... 1m ago Up 1m 8080->8080/tcp ...
Step 4: Open the Hasura console
-------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Head to http://localhost:8080/console to open the Hasura console.
Step 5: Track existing tables and relationships
-----------------------------------------------
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See :ref:`schema_existing_db` to enable GraphQL over the database.
.. _docker_secure:
Securing the GraphQL endpoint
-----------------------------
To make sure that your GraphQL endpoint and the Hasura console are not publicly accessible, you need to
configure an admin secret key.
Run the Docker command with an admin-secret env var
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
:emphasize-lines: 5
#! /bin/bash
docker run -d -p 8080:8080 \
-e HASURA_GRAPHQL_DATABASE_URL=postgres://username:password@hostname:port/dbname \
-e HASURA_GRAPHQL_ENABLE_CONSOLE=true \
-e HASURA_GRAPHQL_ADMIN_SECRET=myadminsecretkey \
hasura/graphql-engine:latest
.. note::
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 :ref:`auth` for information on
setting up authentication.
.. _docker_logs:
Hasura GraphQL engine server logs
---------------------------------
You can check the logs of the Hasura GraphQL engine deployed using Docker by checking the logs of the
GraphQL engine container:
.. code-block:: bash
$ docker ps
CONTAINER ID IMAGE ...
cdfbc6b94c70 hasura/graphql-engine.. ...
$ docker logs cdfbc6b94c70
{"timestamp":"2018-10-09T11:20:32.054+0000", "level":"info", "type":"http-log", "detail":{"status":200, "query_hash":"01640c6dd131826cff44308111ed40d7fbd1cbed", "http_version":"HTTP/1.1", "query_execution_time":3.0177627e-2, "request_id":null, "url":"/v1/graphql", "user":{"x-hasura-role":"admin"}, "ip":"127.0.0.1", "response_size":209329, "method":"POST", "detail":null}}
...
**See:**
- https://docs.docker.com/config/containers/logging for more details on logging in Docker.
- :ref:`hge_logs` for more details on Hasura logs.
.. _docker_update:
Updating Hasura GraphQL engine
------------------------------
This guide will help you update the Hasura GraphQL engine running with Docker. This guide assumes that you already have
Hasura GraphQL engine running with Docker.
Step 1: Check the latest release version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The current latest version is:
.. raw:: html
<code>hasura/graphql-engine:<span class="latest-release-tag">latest</span></code>
All the versions can be found at: https://github.com/hasura/graphql-engine/releases
Step 2: Update the Docker image
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In the ``docker run`` command or the ``docker-compose`` command that you're running, update the image tag to this
latest version.
For example, if you had:
.. raw:: html
<code>docker run hasura/graphql-engine:v1.0.0-alpha01 ...</code>
you should change it to:
.. raw:: html
<code>docker run hasura/graphql-engine:<span class="latest-release-tag">latest</span> ...</code>
.. note::
If you are downgrading to an older version of the GraphQL engine you might need to downgrade your metadata catalogue version
as described in :ref:`downgrade_hge`
Advanced
--------
- :ref:`Securing your GraphQL endpoint <docker_secure>`
- :ref:`GraphQL engine server logs <docker_logs>`
- :ref:`Updating GraphQL engine <docker_update>`
- :ref:`Setting up migrations <migrations>`
.. toctree::
:titlesonly:
:hidden:
Securing your GraphQL endpoint <securing-graphql-endpoint>
GraphQL engine server logs <logging>
Updating GraphQL engine <updating>

View File

@ -12,6 +12,9 @@ Hasura GraphQL engine on Google Cloud Platform with Kubernetes engine and Cloud
:depth: 1
:local:
Introduction
------------
This is a guide on deploying the Hasura GraphQL engine on the `Google Cloud Platform
<https://cloud.google.com/>`__ using `Kubernetes engine
<https://cloud.google.com/kubernetes-engine/>`__ to run Hasura and PosgreSQL
@ -185,8 +188,10 @@ command below. It usually takes a couple of minutes.
Once the IP is allocated, visit the IP in a browser and it should open the
console.
Troubleshooting
---------------
.. _gc_kubernetes_logs:
Logs
----
Check the status for pods to see if they are running. If there are any errors,
check the logs of the GraphQL engine:

View File

@ -0,0 +1,341 @@
.. meta::
:description: Deploy Hasura GraphQL engine with Heroku
:keywords: hasura, docs, deployment, heroku
.. _deploy_heroku:
Run Hasura GraphQL engine on Heroku
===================================
.. contents:: Table of contents
:backlinks: none
:depth: 2
:local:
Introduction
------------
This guide shows how to deploy Hasura GraphQL engine on Heroku.
Deploying Hasura with a new Postgres DB
---------------------------------------
.. _heroku_one_click:
Option 1: One-click deployment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Click the below button to deploy Hasura on Heroku in a few seconds:
.. image:: https://camo.githubusercontent.com/83b0e95b38892b49184e07ad572c94c8038323fb/68747470733a2f2f7777772e6865726f6b7563646e2e636f6d2f6465706c6f792f627574746f6e2e737667
:width: 200px
:alt: heroku_deploy_button
:class: no-shadow
:target: https://heroku.com/deploy?template=https://github.com/hasura/graphql-engine-heroku
.. note::
If you don't have an account on Heroku, you need to sign up on Heroku. You won't need a credit card, and once you
sign up you'll be redirected to your Heroku app creation page automatically.
.. thumbnail:: /img/graphql/manual/guides/heroku-app.png
:alt: Deploy to Heroku
Heroku's free Postgres add-on is automatically provisioned.
.. _heroku_cli_deployment:
Option 2: Deploy via Heroku CLI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Follow these instructions to create a new Heroku app with a Postgres add-on using the Heroku CLI.
Step 1: Clone the Hasura GraphQL engine Heroku app
**************************************************
The Hasura app with Heroku buildpack/configuration is available at:
https://github.com/hasura/graphql-engine-heroku
Step 2: Create an app with **--stack=container**
************************************************
Use the `Heroku CLI <https://devcenter.heroku.com/articles/heroku-cli>`__ to create a new Heroku app from inside the cloned directory. Let's call
the app ``graphql-on-postgres``.
.. code-block:: bash
# Replace graphql-on-postgres with whatever you'd like your app to be called
$ heroku create graphql-on-postgres --stack=container
Creating ⬢ graphql-on-postgres... done, stack is container
https://graphql-on-postgres.herokuapp.com/ | https://git.heroku.com/graphql-on-postgres.git
**Note**:
- ``HEROKU_GIT_REMOTE``: `https://git.heroku.com/graphql-on-postgres.git`
- ``HEROKU_APP_URL``: `https://graphql-on-postgres.herokuapp.com/`
Step 3: Create the Heroku Postgres add-on
*****************************************
Create the Postgres add-on in your Heroku app.
.. code-block:: bash
$ heroku addons:create heroku-postgresql:hobby-dev -a graphql-on-postgres
Creating heroku-postgresql:hobby-dev on ⬢ graphql-on-postgres... free
Database has been created and is available
! This database is empty. If upgrading, you can transfer
! data from another database with pg:copy
Created postgresql-angular-20334 as DATABASE_URL
Use heroku addons:docs heroku-postgresql to view documentation
Step 4: **git push** to deploy
******************************
Remember to change ``HEROKU_GIT_REMOTE`` to your git remote below. In our case:
``https://git.heroku.com/graphql-on-postgres.git``.
.. code-block:: bash
$ git init && git add .
$ git commit -m "first commit"
$ git remote add heroku HEROKU_GIT_REMOTE
$ git push heroku master
Visit ``https://graphql-on-postgres.herokuapp.com`` (replace ``graphql-on-postgres`` with your app name) and
you should see the Hasura console.
.. _heroku_existing_db:
Deploying using an existing Postgres DB
---------------------------------------
Let's say you have an existing `Heroku Postgres <https://www.heroku.com/postgres>`__ database with data in it, and you'd
like to add GraphQL to it.
.. note::
In case you're exposing an existing database (esp. if it is production), please :ref:`configure an admin secret key <heroku_secure>`
for the console and the GraphQL endpoint.
Option 1: Via Heroku UI
^^^^^^^^^^^^^^^^^^^^^^^
Step 1: Deploy Hasura on Heroku
*******************************
Deploy Hasura on Heroku as described in :ref:`this section <heroku_one_click>`.
Step 2: Remove the created Postgres add-on in the app
*****************************************************
Head to your Heroku dashboard and delete the Postgres add-on created in the previous step:
.. thumbnail:: /img/graphql/manual/deployment/remove-heroku-postgres-addon.png
:alt: Delete the Postgres add-on
Step 3: Configure environment variables
***************************************
Now configure the ``DATABASE_URL`` with your existing Heroku Postgres database URL and a ``HASURA_GRAPHQL_ADMIN_SECRET``
if you want to :ref:`secure your endpoint <heroku_secure>`.
.. thumbnail:: /img/graphql/manual/deployment/heroku-database-url-access.png
:alt: Configure environment variables
.. note::
The Hasura GraphQL engine needs access permissions to your Postgres database as described in
:ref:`Postgres permissions <postgres_permissions>`.
Step 4: Track tables and relationships
**************************************
Wait for the GraphQL engine to restart and then see :ref:`schema_existing_db` to enable GraphQL
over the database.
Option 2: Via Heroku CLI
^^^^^^^^^^^^^^^^^^^^^^^^
You can set up the Hasura GraphQL engine as a "git push to deploy" app on
`Heroku <https://www.heroku.com/platform>`__ and connect it to a `Heroku Postgres <https://www.heroku.com/postgres>`__
instance.
Step 1: Clone the Hasura GraphQL engine Heroku app
**************************************************
The Hasura app with Heroku buildpack/configuration is available at:
https://github.com/hasura/graphql-engine-heroku
Step 2: Configure the database URL
**********************************
Edit the command in the ``Dockerfile`` to change which database the Hasura GraphQL engine connects to.
By default, it connects to the primary database in your app which is available at ``DATABASE_URL``.
.. code-block:: dockerfile
:emphasize-lines: 6
FROM hasura/graphql-engine:latest
# Change $DATABASE_URL to your Heroku Postgres URL if you're not using
# the primary Postgres instance in your app
CMD graphql-engine \
--database-url $DATABASE_URL \
serve \
--server-port $PORT \
--enable-console
Read about more configuration options :ref:`here <server_flag_reference>`.
.. note::
Hasura GraphQL engine needs access permissions to your Postgres database as described in
:ref:`Postgres permissions <postgres_permissions>`.
.. _heroku_secure:
Securing the GraphQL endpoint
-----------------------------
To make sure that your GraphQL endpoint and the Hasura console are not publicly accessible, you need to
configure an admin secret key.
Add an admin secret
^^^^^^^^^^^^^^^^^^^
Head to the config-vars URL on your Heroku dashboard and set the ``HASURA_GRAPHQL_ADMIN_SECRET`` environment variable.
.. thumbnail:: /img/graphql/manual/deployment/secure-heroku.png
:alt: Add an admin secret
Setting this environment variable will automatically restart the dyno. Now when you access your console, you'll be
prompted for the admin secret key.
.. thumbnail:: /img/graphql/manual/deployment/access-key-console.png
:alt: Prompt for the admin secret
.. note::
The ``HASURA_GRAPHQL_ADMIN_SECRET`` should never be passed from the client to Hasura GraphQL engine as it would
give the client full admin rights to your Hasura instance. See :ref:`auth` for information on
setting up authentication.
(optional) Use the admin secret with the CLI
********************************************
In case you're using the CLI to open the Hasura console, use the ``admin-secret`` flag when you open the console:
.. code-block:: bash
hasura console --admin-secret=myadminsecretkey
.. _heroku_logs:
GraphQL engine server logs
--------------------------
You can use the `Heroku CLI <https://devcenter.heroku.com/articles/heroku-cli>`__ to check the logs
of the Hasura GraphQL engine deployed on Heroku:
.. code-block:: bash
$ heroku logs --app <hasura-graphql-engine-app-name>
2018-10-09T11:18:21.306000+00:00 app[web.1]: {"timestamp":"2018-10-09T11:18:21.305+0000", "level":"info", "type":"http-log", "detail":{"status":200, "query_hash":"48c74f902b53a886f9ddc1b7dd12a4a6020d70c3", "http_version":"HTTP/1.1", "query_execution_time":9.477913e-3, "request_id":"b7bb6fb3-97b3-4c6f-a54a-1e0f71a190e9", "url":"/v1/graphql", "user":{"x-hasura-role":"admin"}, "ip":"171.61.77.16", "response_size":15290, "method":"POST", "detail":null}}
...
**See:**
- https://devcenter.heroku.com/articles/logging for more details on logging on Heroku.
- :ref:`hge_logs` for more details on Hasura logs
.. _heroku_update:
Updating GraphQL engine
-----------------------
This section will help you update the Hasura GraphQL engine running on Heroku.
The current latest version is:
.. raw:: html
<code>hasura/graphql-engine:<span class="latest-release-tag">latest</span></code>
Update to the latest version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Step 1: Clone the Hasura GraphQL engine Heroku app
**************************************************
The Hasura app with Heroku buildpack/configuration is available at:
https://github.com/hasura/graphql-engine-heroku.
Clone the above repository.
.. code-block:: bash
git clone https://github.com/hasura/graphql-engine-heroku
cd graphql-engine-heroku
If you already have this, then pull the latest changes which will have the updated GraphQL engine Docker image.
Step 2: Attach your Heroku app
******************************
Let's say your Heroku app is called ``hasura-heroku`` and is running on ``https://hasura-heroku.herokuapp.com``.
From inside the ``graphql-engine-heroku`` directory, use the `Heroku CLI <https://devcenter.heroku.com/articles/heroku-cli>`__ to configure the git repo you cloned in Step 1
to be able to push to this app.
.. code-block:: bash
# Replace <hasura-heroku> with your Heroku app's name
heroku git:remote -a <hasura-heroku>
heroku stack:set container -a <hasura-heroku>
You can find your Heroku git repo in your Heroku - Settings - Info - Heroku Git URL
Step 3: **git push** to deploy the latest Hasura GraphQL engine
***************************************************************
When you ``git push`` to deploy, the Heroku app will get updated with the latest changes:
.. code-block:: bash
git push heroku master
Deploy a specific version
^^^^^^^^^^^^^^^^^^^^^^^^^
Head to the ``Dockerfile`` in the git repo you cloned in step 1.
Change the ``FROM`` line to the specific version you want. A list of all releases can be found
at https://github.com/hasura/graphql-engine/releases.
.. code-block:: Dockerfile
:emphasize-lines: 1
FROM hasura/graphql-engine:v1.0.0
...
...
Change ``v1.0.0`` to ``v1.1.0`` for example, commit this and then ``git push heroku master`` to deploy.
.. note::
If you are downgrading to an older version of the GraphQL engine you might need to downgrade your metadata catalogue version
as described in :ref:`downgrade_hge`
Advanced
--------
- :ref:`Setting up migrations <migrations>`

View File

@ -0,0 +1,69 @@
.. meta::
:description: Deploy Hasura GraphQL engine
:keywords: hasura, docs, deployment
.. _deployment_guides:
Deployment guides
=================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
Introduction
------------
The Hasura GraphQL engine is a binary that is shipped as a Docker container.
Choose from the below guides to deploy the Hasura GraphQL engine and connect it to a Postgres database.
.. _one_click_deployment_guides:
One-click deployment options
----------------------------
If you want to take Hasura for a spin and check out the features, the following one-click deployments will be useful for you:
- `Deploy using Hasura Cloud <https://hasura.io/docs/cloud/1.0/manual/getting-started/index.html>`__ (**recommended**)
- :ref:`Deploy using Heroku <heroku_one_click>`
- :ref:`Deploy using Render One-click Deploy with Managed PostgreSQL <deploy_render>`
- :ref:`Deploy using Nhost One-click Deploy with Managed PostgreSQL, Storage, and Auth <deploy_nhost>`
.. _all_deployment_guides:
Deployment guides
-----------------
Choose from the full list of deployment guides:
- `Deploy using Hasura Cloud <https://hasura.io/docs/cloud/1.0/manual/getting-started/index.html>`__ (**recommended**)
- :ref:`Deploy using Docker <deployment_docker>`
- :ref:`Deploy using Kubernetes <deploy_kubernetes>`
- :ref:`Deploy using Heroku <deploy_heroku>`
- :ref:`Deploy using Digital Ocean One-click App on Marketplace <deploy_do_marketplace>`
- :ref:`Deploy using Azure Container Instances with Postgres <deploy_azure_ci_pg>`
- :ref:`Deploy using Google Cloud Platform with Kubernetes engine and Cloud SQL <deploy_gc_kubernetes>`
- `Deploy using Instant GraphQL on AWS RDS (blog) <https://hasura.io/blog/instant-graphql-on-aws-rds-1edfb85b5985>`__
- :ref:`Deploy using Render One-click Deploy with Managed PostgreSQL <deploy_render>`
- :ref:`Deploy using Nhost One-click Deploy with Managed PostgreSQL, Storage, and Auth <deploy_nhost>`
.. admonition:: Custom Docker images or binaries
If you need a custom Docker image or binary for GraphQL engine, please see :ref:`this page <custom_docker_image>`.
.. toctree::
:maxdepth: 1
:titlesonly:
:hidden:
Using Hasura Cloud <https://hasura.io/docs/cloud/1.0/manual/getting-started/index.html>
Using Docker <docker>
Using Kubernetes <kubernetes>
Using Heroku (one-click) <heroku>
Using DigitalOcean (one-click) <digital-ocean-one-click>
Using Azure Container Instances <azure-container-instances-postgres>
Using Google Cloud Platform & Kubernetes <google-kubernetes-engine-cloud-sql>
Using Render (one-click) <render-one-click>
Using Nhost (one-click) <nhost-one-click>

View File

@ -0,0 +1,227 @@
.. meta::
:description: Deploy Hasura GraphQL engine with Kubernetes
:keywords: hasura, docs, deployment, kubernetes
.. _deploy_kubernetes:
Run Hasura GraphQL engine on Kubernetes
=======================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
Introduction
------------
This guide assumes that you already have Postgres running and helps you set up the Hasura GraphQL engine on Kubernetes
and connect it to your Postgres database.
Deploying Hasura using Kubernetes
---------------------------------
Step 1: Get the Kubernetes deployment and service files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The `hasura/graphql-engine/install-manifests <https://github.com/hasura/graphql-engine/tree/stable/install-manifests>`__ repo
contains all installation manifests required to deploy Hasura anywhere. Get the Kubernetes deployment and service files
from there:
.. code-block:: bash
$ wget https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/kubernetes/deployment.yaml
$ wget https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/kubernetes/svc.yaml
Step 2: Set the Postgres database url
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Edit ``deployment.yaml`` and set the right database url:
.. code-block:: yaml
:emphasize-lines: 4
...
env:
- name: HASURA_GRAPHQL_DATABASE_URL
value: postgres://username:password@hostname:port/dbname
...
Examples of ``HASURA_GRAPHQL_DATABASE_URL``:
- ``postgres://admin:password@localhost:5432/my-db``
- ``postgres://admin:@localhost:5432/my-db`` *(if there is no password)*
.. note::
- If your **password contains special characters** (e.g. #, %, $, @, etc.), you need to URL encode them in the
``HASURA_GRAPHQL_DATABASE_URL`` env var (e.g. %40 for @).
You can check the :ref:`logs <kubernetes_logs>` to see if the database credentials are proper and if Hasura is able
to connect to the database.
- The Hasura GraphQL engine needs access permissions on your Postgres database as described in
:ref:`Postgres permissions <postgres_permissions>`.
Step 3: Create the Kubernetes deployment and service
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
$ kubectl create -f deployment.yaml
$ kubectl create -f svc.yaml
Step 4: Open the Hasura console
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The above creates a LoadBalancer type service with port 80. So you should be able to access the console at the
external IP.
For example, using Docker-for-desktop on Mac:
.. code-block:: bash
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hasura LoadBalancer 10.96.214.240 localhost 80:30303/TCP 4m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8m
Head to: http://localhost and the console should load!
Step 5: Track existing tables and relationships
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See :ref:`schema_existing_db` to enable GraphQL over the database.
.. _kubernetes_secure:
Securing the GraphQL endpoint
-----------------------------
To make sure that your GraphQL endpoint and the Hasura console are not publicly accessible, you need to
configure an admin secret key.
Add the HASURA_GRAPHQL_ADMIN_SECRET env var
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Update the ``deployment.yaml`` to set the ``HASURA_GRAPHQL_ADMIN_SECRET`` environment variable.
.. code-block:: yaml
:emphasize-lines: 10,11
...
spec:
containers:
...
command: ["graphql-engine"]
args: ["serve", "--enable-console"]
env:
- name: HASURA_GRAPHQL_DATABASE_URL
value: postgres://username:password@hostname:port/dbname
- name: HASURA_GRAPHQL_ADMIN_SECRET
value: mysecretkey
ports:
- containerPort: 8080
protocol: TCP
resources: {}
.. note::
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 :ref:`auth` for information on
setting up authentication.
(optional) Use the admin secret key with the CLI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In case you're using the CLI to open the Hasura console, use the ``admin-secret`` flag when you open the console:
.. code-block:: bash
hasura console --admin-secret=myadminsecretkey
.. _kubernetes_logs:
Hasura GraphQL engine server logs
---------------------------------
You can check the logs of the Hasura GraphQL engine deployed on Kubernetes by checking the logs of the GraphQL engine
service, i.e. ``hasura``:
.. code-block:: bash
$ kubectl logs -f svc/hasura
{"timestamp":"2018-10-09T11:20:32.054+0000", "level":"info", "type":"http-log", "detail":{"status":200, "query_hash":"01640c6dd131826cff44308111ed40d7fbd1cbed", "http_version":"HTTP/1.1", "query_execution_time":3.0177627e-2, "request_id":null, "url":"/v1/graphql", "user":{"x-hasura-role":"admin"}, "ip":"127.0.0.1", "response_size":209329, "method":"POST", "detail":null}}
...
**See:**
- https://kubernetes.io/docs/concepts/cluster-administration/logging for more details on logging in Kubernetes.
- :ref:`hge_logs` for more details on Hasura logs
.. _kubernetes_update:
Updating Hasura GraphQL engine
------------------------------
This guide will help you update the Hasura GraphQL engine running on Kubernetes. This guide assumes that you already have
the Hasura GraphQL engine running on Kubernetes.
Step 1: Check the latest release version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The current latest version is:
.. raw:: html
<code>hasura/graphql-engine:<span class="latest-release-tag">latest</span></code>
All the versions can be found at: https://github.com/hasura/graphql-engine/releases.
Step 2: Update the container image
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In the ``deployment.yaml`` file, update the image tag to this latest version.
For example, if you had:
.. raw:: html
<code>
containers:<br>
- image: hasura/graphql-engine:v1.0.0-alpha01
</code>
you should change it to:
.. raw:: html
<code>
containers:<br>
- image: hasura/graphql-engine:<span class="latest-release-tag">latest</span>
</code>
Step 3: Rollout the change
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
$ kubectl replace -f deployment.yaml
.. note::
If you are downgrading to an older version of the GraphQL engine you might need to downgrade your metadata catalogue version
as described in :ref:`downgrade_hge`
Advanced
--------
- :ref:`Setting up migrations <migrations>`

View File

@ -17,7 +17,7 @@ Introduction
This guide shows how to deploy the Hasura GraphQL engine on `Nhost <https://nhost.io>`__.
One-Click deploy on Nhost
One-click deploy on Nhost
-------------------------
.. note::

View File

@ -12,9 +12,12 @@ Deploying Hasura GraphQL engine on Render
:depth: 1
:local:
Introduction
------------
This guide shows how to deploy the Hasura GraphQL engine on `Render <https://render.com>`__.
One-Click Deploy on Render
One-click Deploy on Render
--------------------------
.. note::

View File

@ -1,34 +0,0 @@
.. meta::
:description: Get Hasura GraphQL engine server logs with Docker deployment
:keywords: hasura, docs, deployment, docker, logs
.. _docker_logs:
Hasura GraphQL engine server logs (Docker)
==========================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
You can check the logs of the Hasura GraphQL engine deployed using Docker by checking the logs of the
GraphQL engine container:
.. code-block:: bash
$ docker ps
CONTAINER ID IMAGE ...
cdfbc6b94c70 hasura/graphql-engine.. ...
$ docker logs cdfbc6b94c70
{"timestamp":"2018-10-09T11:20:32.054+0000", "level":"info", "type":"http-log", "detail":{"status":200, "query_hash":"01640c6dd131826cff44308111ed40d7fbd1cbed", "http_version":"HTTP/1.1", "query_execution_time":3.0177627e-2, "request_id":null, "url":"/v1/graphql", "user":{"x-hasura-role":"admin"}, "ip":"127.0.0.1", "response_size":209329, "method":"POST", "detail":null}}
...
**See:**
- https://docs.docker.com/config/containers/logging for more details on logging in Docker.
- :ref:`hge_logs` for more details on Hasura logs.

View File

@ -1,36 +0,0 @@
.. meta::
:description: Secure Hasura GraphQL endpoint with Docker deployment
:keywords: hasura, docs, deployment, docker, secure
.. _docker_secure:
Securing the GraphQL endpoint (Docker)
======================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
To make sure that your GraphQL endpoint and the Hasura console are not publicly accessible, you need to
configure an admin secret key.
Run the Docker command with an admin-secret env var
---------------------------------------------------
.. code-block:: bash
:emphasize-lines: 5
#! /bin/bash
docker run -d -p 8080:8080 \
-e HASURA_GRAPHQL_DATABASE_URL=postgres://username:password@hostname:port/dbname \
-e HASURA_GRAPHQL_ENABLE_CONSOLE=true \
-e HASURA_GRAPHQL_ADMIN_SECRET=myadminsecretkey \
hasura/graphql-engine:latest
.. note::
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 :ref:`auth` for information on
setting up authentication.

View File

@ -1,50 +0,0 @@
.. meta::
:description: Update Hasura GraphQL engine with Docker deployment
:keywords: hasura, docs, deployment, docker, update
.. _docker_update:
Updating Hasura GraphQL engine running with Docker
==================================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
This guide will help you update the Hasura GraphQL engine running with Docker. This guide assumes that you already have
Hasura GraphQL engine running with Docker.
Step 1: Check the latest release version
----------------------------------------
The current latest version is:
.. raw:: html
<code>hasura/graphql-engine:<span class="latest-release-tag">latest</span></code>
All the versions can be found at: https://github.com/hasura/graphql-engine/releases
Step 2: Update the Docker image
-------------------------------
In the ``docker run`` command or the ``docker-compose`` command that you're running, update the image tag to this
latest version.
For example, if you had:
.. raw:: html
<code>docker run hasura/graphql-engine:v1.0.0-alpha01 ...</code>
you should change it to:
.. raw:: html
<code>docker run hasura/graphql-engine:<span class="latest-release-tag">latest</span> ...</code>
.. note::
If you are downgrading to an older version of the GraphQL engine you might need to downgrade your metadata catalogue version
as described in :ref:`downgrade_hge`

View File

@ -1,125 +0,0 @@
.. meta::
:description: Deploy Hasura GraphQL engine with Heroku
:keywords: hasura, docs, deployment, heroku
.. _deploy_heroku:
Run Hasura GraphQL engine on Heroku
===================================
.. contents:: Table of contents
:backlinks: none
:depth: 2
:local:
This guide will help you get the Hasura GraphQL engine running as a "git push to deploy" app on
`Heroku <https://www.heroku.com/platform>`__ and connecting it to a `Heroku Postgres <https://www.heroku.com/postgres>`__
instance. If you want a simple, quick deployment on Heroku, follow this :ref:`Heroku one-click
guide <heroku_one_click>`.
Clone the Hasura GraphQL engine Heroku app
------------------------------------------
The Hasura app with Heroku buildpack/configuration is available at:
https://github.com/hasura/graphql-engine-heroku
Configure database URL
^^^^^^^^^^^^^^^^^^^^^^
Edit the command in the ``Dockerfile`` to change which database the Hasura GraphQL engine connects to.
By default, it connects to the primary database in your app which is available at ``DATABASE_URL``.
.. code-block:: dockerfile
:emphasize-lines: 6
FROM hasura/graphql-engine:latest
# Change $DATABASE_URL to your Heroku Postgres URL if you're not using
# the primary Postgres instance in your app
CMD graphql-engine \
--database-url $DATABASE_URL \
serve \
--server-port $PORT \
--enable-console
Read about more configuration options :ref:`here <server_flag_reference>`.
.. note::
Hasura GraphQL engine needs access permissions to your Postgres database as described in
:ref:`Postgres permissions <postgres_permissions>`.
Deploying
---------
These are some sample deployment instructions while creating a new app.
Step 1: Create an app with **--stack=container**
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Use the `Heroku CLI <https://devcenter.heroku.com/articles/heroku-cli>`__ to create a new Heroku app. Let's call
the app ``graphql-on-postgres``.
.. code-block:: bash
# Replace graphql-on-postgres with whatever you'd like your app to be called
$ heroku create graphql-on-postgres --stack=container
Creating ⬢ graphql-on-postgres... done, stack is container
https://graphql-on-postgres.herokuapp.com/ | https://git.heroku.com/graphql-on-postgres.git
**Note**:
- ``HEROKU_GIT_REMOTE``: `https://git.heroku.com/graphql-on-postgres.git`
- ``HEROKU_APP_URL``: `https://graphql-on-postgres.herokuapp.com/`
Step 2: Create the Heroku Postgres add-on
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Create the Postgres add-on in your Heroku app.
.. code-block:: bash
$ heroku addons:create heroku-postgresql:hobby-dev -a graphql-on-postgres
Creating heroku-postgresql:hobby-dev on ⬢ graphql-on-postgres... free
Database has been created and is available
! This database is empty. If upgrading, you can transfer
! data from another database with pg:copy
Created postgresql-angular-20334 as DATABASE_URL
Use heroku addons:docs heroku-postgresql to view documentation
Step 3: **git push** to deploy
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remember to change ``HEROKU_GIT_REMOTE`` to your git remote below. In our case:
``https://git.heroku.com/graphql-on-postgres.git``.
.. code-block:: bash
$ git init && git add .
$ git commit -m "first commit"
$ git remote add heroku HEROKU_GIT_REMOTE
$ git push heroku master
Visit ``https://graphql-on-postgres.herokuapp.com`` (replace ``graphql-on-postgres`` with your app name) and
you should see the Hasura console.
Advanced
--------
- :ref:`Securing your GraphQL endpoint <heroku_secure>`
- :ref:`heroku_existing_db`
- :ref:`GraphQL engine server logs <heroku_logs>`
- :ref:`Updating GraphQL engine <heroku_update>`
- :ref:`Setting up migrations <migrations>`
.. toctree::
:titlesonly:
:hidden:
Securing your GraphQL endpoint <securing-graphql-endpoint>
using-existing-heroku-database
GraphQL engine server logs <logging>
Updating GraphQL engine <updating>

View File

@ -1,29 +0,0 @@
.. meta::
:description: Get Hasura GraphQL engine server logs with Heroku deployment
:keywords: hasura, docs, deployment, heroku, logs
.. _heroku_logs:
Hasura GraphQL engine server logs (Heroku)
==========================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
You can use the `Heroku CLI <https://devcenter.heroku.com/articles/heroku-cli>`__ to check the logs
of the Hasura GraphQL engine deployed on Heroku:
.. code-block:: bash
$ heroku logs --app <hasura-graphql-engine-app-name>
2018-10-09T11:18:21.306000+00:00 app[web.1]: {"timestamp":"2018-10-09T11:18:21.305+0000", "level":"info", "type":"http-log", "detail":{"status":200, "query_hash":"48c74f902b53a886f9ddc1b7dd12a4a6020d70c3", "http_version":"HTTP/1.1", "query_execution_time":9.477913e-3, "request_id":"b7bb6fb3-97b3-4c6f-a54a-1e0f71a190e9", "url":"/v1/graphql", "user":{"x-hasura-role":"admin"}, "ip":"171.61.77.16", "response_size":15290, "method":"POST", "detail":null}}
...
**See:**
- https://devcenter.heroku.com/articles/logging for more details on logging on Heroku.
- :ref:`hge_logs` for more details on Hasura logs

View File

@ -1,48 +0,0 @@
.. meta::
:description: Secure Hasura GraphQL endpoint with Heroku deployment
:keywords: hasura, docs, deployment, heroku, secure
.. _heroku_secure:
Securing the GraphQL endpoint (Heroku)
======================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
To make sure that your GraphQL endpoint and the Hasura console are not publicly accessible, you need to
configure an admin secret key.
Add the HASURA_GRAPHQL_ADMIN_SECRET env var
-------------------------------------------
Head to the config-vars URL on your Heroku dashboard and set the ``HASURA_GRAPHQL_ADMIN_SECRET`` environment variable.
.. thumbnail:: /img/graphql/manual/deployment/secure-heroku.png
:alt: Add an admin secret
Setting this environment variable will automatically restart the dyno. Now when you access your console, you'll be
prompted for the admin secret key.
.. thumbnail:: /img/graphql/manual/deployment/access-key-console.png
:alt: Prompt for the admin secret
.. note::
The ``HASURA_GRAPHQL_ADMIN_SECRET`` should never be passed from the client to Hasura GraphQL engine as it would
give the client full admin rights to your Hasura instance. See :ref:`auth` for information on
setting up authentication.
(optional) Use the admin secret with the CLI
--------------------------------------------
In case you're using the CLI to open the Hasura console, use the ``admin-secret`` flag when you open the console:
.. code-block:: bash
hasura console --admin-secret=myadminsecretkey

View File

@ -1,86 +0,0 @@
.. meta::
:description: Update Hasura GraphQL engine with Heroku deployment
:keywords: hasura, docs, deployment, heroku, update
.. _heroku_update:
Updating Hasura GraphQL engine on Heroku
========================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
This guide will help you update the Hasura GraphQL engine running on Heroku. This guide assumes that you already have a
Hasura GraphQL engine running on Heroku.
The current latest version is:
.. raw:: html
<code>hasura/graphql-engine:<span class="latest-release-tag">latest</span></code>
Follow these steps to update Hasura GraphQL engine to the lastest version:
Step 1: Clone the Hasura GraphQL engine Heroku app
--------------------------------------------------
The Hasura app with Heroku buildpack/configuration is available at:
https://github.com/hasura/graphql-engine-heroku.
Clone the above repository.
.. code-block:: bash
git clone https://github.com/hasura/graphql-engine-heroku
cd graphql-engine-heroku
If you already have this, then pull the latest changes which will have the updated GraphQL engine Docker image.
Step 2: Attach your Heroku app
------------------------------
Let's say your Heroku app is called ``hasura-heroku`` and is running on ``https://hasura-heroku.herokuapp.com``.
Navigate to your project directory, use the `Heroku CLI <https://devcenter.heroku.com/articles/heroku-cli>`__ to configure the git repo you cloned in Step 1
to be able to push to this app.
.. code-block:: bash
# Replace <hasura-heroku> with your Heroku app's name
heroku git:remote -a <hasura-heroku>
heroku stack:set container -a <hasura-heroku>
You can find your Heroku git repo in your Heroku - Settings - Info - Heroku Git URL
Step 3: **git push** to deploy the latest Hasura GraphQL engine
---------------------------------------------------------------
When you ``git push`` to deploy, the Heroku app will get updated with the latest changes:
.. code-block:: bash
git push heroku master
Deploy a specific version of the Hasura GraphQL engine
------------------------------------------------------
Head to the ``Dockerfile`` in the git repo you cloned in step 1.
Change the ``FROM`` line to the specific version you want. A list of all releases can be found
at https://github.com/hasura/graphql-engine/releases.
.. code-block:: Dockerfile
:emphasize-lines: 1
FROM hasura/graphql-engine:v1.0.0
...
...
Change ``v1.0.0`` to ``v1.1.0`` for example, commit this and then ``git push heroku master`` to deploy.
.. note::
If you are downgrading to an older version of the GraphQL engine you might need to downgrade your metadata catalogue version
as described in :ref:`downgrade_hge`

View File

@ -1,65 +0,0 @@
.. meta::
:description: Use an existing database with Heroku deployment
:keywords: hasura, docs, deployment, heroku, existing database
.. _heroku_existing_db:
Using an existing Heroku database
=================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
Let's say you have an existing `Heroku Postgres <https://www.heroku.com/postgres>`__ database with data in it, and you'd
like add GraphQL on it.
.. note::
In case you're exposing an existing database (esp. if it is production), please configure an admin secret key
for the console and the GraphQL endpoint.
Step 1: Deploy Hasura on Heroku
-------------------------------
Deploy Hasura on Heroku by clicking on this button:
.. image:: https://camo.githubusercontent.com/83b0e95b38892b49184e07ad572c94c8038323fb/68747470733a2f2f7777772e6865726f6b7563646e2e636f6d2f6465706c6f792f627574746f6e2e737667
:width: 200px
:alt: heroku_deploy_button
:class: no-shadow
:target: https://heroku.com/deploy?template=https://github.com/hasura/graphql-engine-heroku
Follow the Heroku instructions to deploy, check if the Hasura console loads up when you click on **View app** and then head
to the **Manage App** screen on your Heroku dashboard.
This will deploy Hasura with a free Postgres add-on automatically provisioned.
Step 2: Remove the created Postgres add-on in the app
-----------------------------------------------------
Head to your Heroku dashboard and delete the Postgres add-on created in the previous step:
.. thumbnail:: /img/graphql/manual/deployment/remove-heroku-postgres-addon.png
:alt: Delete the Postgres add-on
Step 3: Configure environment variables
---------------------------------------
Now configure the ``DATABASE_URL`` with your existing Heroku Postgres database URL and a ``HASURA_GRAPHQL_ADMIN_SECRET``
if you want to secure your endpoint.
.. thumbnail:: /img/graphql/manual/deployment/heroku-database-url-access.png
:alt: Configure environment variables
.. note::
The Hasura GraphQL engine needs access permissions to your Postgres database as described in
:ref:`Postgres permissions <postgres_permissions>`.
Step 4: Track tables and relationships
--------------------------------------
Wait for the GraphQL engine to restart and then see :ref:`schema_existing_db` to enable GraphQL
over the database.

View File

@ -12,28 +12,22 @@ Deploying Hasura GraphQL engine
:depth: 1
:local:
.. note::
This section talks in depth about deploying the Hasura GraphQL engine for a **production-like environment**.
If you would simply like to take the Hasura GraphQL engine for a quick spin, choose from our
:ref:`Getting started guides <getting_started>`.
Deployment guides
-----------------
The Hasura GraphQL engine is a binary that is shipped as a Docker container.
This section contains guides to deploy the Hasura GraphQL engine and connect it to a Postgres database.
Choose from the following guides to deploy the Hasura GraphQL engine and connect it to a Postgres database:
If you're looking for quick deployment options, check out the following guides:
- `Deploy using Hasura Cloud <https://hasura.io/docs/cloud/1.0/manual/getting-started/index.html>`__
- :ref:`Deploy using Heroku <deploy_heroku>`
- :ref:`Deploy using Docker <deployment_docker>`
- :ref:`Deploy using Kubernetes <deploy_kubernetes>`
- :ref:`One-click deployment guides <one_click_deployment_guides>`
You can also check :ref:`guides_deployment` for more specific examples.
The following is a list of all deployment guides:
- :ref:`Deployment guides <all_deployment_guides>`
.. admonition:: Custom Docker images or binaries
If you need a custom Docker image or binary for GraphQL engine, please see :ref:`this page <custom_docker_image>`
If you need a custom Docker image or binary for GraphQL engine, please see :ref:`this page <custom_docker_image>`.
Configuration
@ -42,9 +36,15 @@ Configuration
By default, Hasura GraphQL engine runs in a very permissive mode for easier development. Check out the below pages
to configure the Hasura GraphQL engine for your production environment:
- :ref:`securing_graphql_endpoint`
- :ref:`postgres_permissions`
- :ref:`GraphQL engine server configuration <hge_flags>`
- :ref:`Postgres requirements <postgres_permissions>`
- :ref:`Securing the GraphQL endpoint <securing_graphql_endpoint>`
- :ref:`Enable HTTPS <enable_https>`
- :ref:`Allow-list of operations <allow_list>`
- :ref:`HTTP compression <http_compression>`
- :ref:`Updating GraphQL engine <update_hge>`
- :ref:`Downgrading GraphQL engine <downgrade_hge>`
Logs
----
@ -53,23 +53,28 @@ For access to Hasura GraphQL engine logs, check the below page for details:
- :ref:`Logging <hge_logs>`
Production checklist
--------------------
If you're moving your Hasura GraphQL engine to production, consult the following guide:
- :ref:`Production checklist <production_checklist>`
.. toctree::
:maxdepth: 1
:titlesonly:
:hidden:
Using Heroku <heroku/index>
Using Docker <docker/index>
Using Kubernetes <kubernetes/index>
Deployment guides <deploying/index>
Server configuration <graphql-engine-flags/index>
postgres-requirements
securing-graphql-endpoint
Securing GraphQL endpoint <securing-graphql-endpoint>
Server logs <logging>
Enable HTTPS <enable-https>
allow-list
HTTP Compression <compression>
Production checklist <production-checklist>
Custom Docker images or binaries <custom-docker-images>
Updating GraphQL engine <updating>
Updating GraphQL engine <updating-graphql-engine>
Downgrading GraphQL engine <downgrading>

View File

@ -1,106 +0,0 @@
.. meta::
:description: Deploy Hasura GraphQL engine with Kubernetes
:keywords: hasura, docs, deployment, kubernetes
.. _deploy_kubernetes:
Run Hasura GraphQL engine on Kubernetes
=======================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
This guide assumes that you already have Postgres running and helps you set up the Hasura GraphQL engine on Kubernetes
and connect it to your Postgres database.
Step 1: Get the Kubernetes deployment and service files
-------------------------------------------------------
The `hasura/graphql-engine/install-manifests <https://github.com/hasura/graphql-engine/tree/stable/install-manifests>`__ repo
contains all installation manifests required to deploy Hasura anywhere. Get the Kubernetes deployment and service files
from there:
.. code-block:: bash
$ wget https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/kubernetes/deployment.yaml
$ wget https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/kubernetes/svc.yaml
Step 2: Set the Postgres database url
-------------------------------------
Edit ``deployment.yaml`` and set the right database url:
.. code-block:: yaml
:emphasize-lines: 4
...
env:
- name: HASURA_GRAPHQL_DATABASE_URL
value: postgres://username:password@hostname:port/dbname
...
Examples of ``HASURA_GRAPHQL_DATABASE_URL``:
- ``postgres://admin:password@localhost:5432/my-db``
- ``postgres://admin:@localhost:5432/my-db`` *(if there is no password)*
.. note::
- If your **password contains special characters** (e.g. #, %, $, @, etc.), you need to URL encode them in the
``HASURA_GRAPHQL_DATABASE_URL`` env var (e.g. %40 for @).
You can check the :ref:`logs <kubernetes_logs>` to see if the database credentials are proper and if Hasura is able
to connect to the database.
- The Hasura GraphQL engine needs access permissions on your Postgres database as described in
:ref:`Postgres permissions <postgres_permissions>`.
Step 3: Create the Kubernetes deployment and service
----------------------------------------------------
.. code-block:: bash
$ kubectl create -f deployment.yaml
$ kubectl create -f svc.yaml
Step 4: Open the Hasura console
-------------------------------
The above creates a LoadBalancer type service with port 80. So you should be able to access the console at the
external IP.
For example, using Docker-for-desktop on Mac:
.. code-block:: bash
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hasura LoadBalancer 10.96.214.240 localhost 80:30303/TCP 4m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8m
Head to: http://localhost and the console should load!
Step 5: Track existing tables and relationships
-----------------------------------------------
See :ref:`schema_existing_db` to enable GraphQL over the database.
Advanced
--------
- :ref:`Securing your GraphQL endpoint <kubernetes_secure>`
- :ref:`GraphQL engine server logs <kubernetes_logs>`
- :ref:`Updating GraphQL engine <kubernetes_update>`
- :ref:`Setting up migrations <migrations>`
.. toctree::
:titlesonly:
:hidden:
Securing your GraphQL endpoint <securing-graphql-endpoint>
GraphQL engine server logs <logging>
Updating GraphQL engine <updating>

View File

@ -1,30 +0,0 @@
.. meta::
:description: Get Hasura GraphQL engine server logs with Kubernetes deployment
:keywords: hasura, docs, deployment, kubernetes, logs
.. _kubernetes_logs:
Hasura GraphQL engine server logs (Kubernetes)
==============================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
You can check the logs of the Hasura GraphQL engine deployed on Kubernetes by checking the logs of the GraphQL engine
service, i.e. ``hasura``:
.. code-block:: bash
$ kubectl logs -f svc/hasura
{"timestamp":"2018-10-09T11:20:32.054+0000", "level":"info", "type":"http-log", "detail":{"status":200, "query_hash":"01640c6dd131826cff44308111ed40d7fbd1cbed", "http_version":"HTTP/1.1", "query_execution_time":3.0177627e-2, "request_id":null, "url":"/v1/graphql", "user":{"x-hasura-role":"admin"}, "ip":"127.0.0.1", "response_size":209329, "method":"POST", "detail":null}}
...
**See:**
- https://kubernetes.io/docs/concepts/cluster-administration/logging for more details on logging in Kubernetes.
- :ref:`hge_logs` for more details on Hasura logs

View File

@ -1,57 +0,0 @@
.. meta::
:description: Secure Hasura GraphQL endpoint with Kubernetes deployment
:keywords: hasura, docs, deployment, kubernetes, secure
.. _kubernetes_secure:
Securing the GraphQL endpoint (Kubernetes)
==========================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
To make sure that your GraphQL endpoint and the Hasura console are not publicly accessible, you need to
configure an admin secret key.
Add the HASURA_GRAPHQL_ADMIN_SECRET env var
-------------------------------------------
Update the ``deployment.yaml`` to set the ``HASURA_GRAPHQL_ADMIN_SECRET`` environment variable.
.. code-block:: yaml
:emphasize-lines: 10,11
...
spec:
containers:
...
command: ["graphql-engine"]
args: ["serve", "--enable-console"]
env:
- name: HASURA_GRAPHQL_DATABASE_URL
value: postgres://username:password@hostname:port/dbname
- name: HASURA_GRAPHQL_ADMIN_SECRET
value: mysecretkey
ports:
- containerPort: 8080
protocol: TCP
resources: {}
.. note::
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 :ref:`auth` for information on
setting up authentication.
(optional) Use the admin secret key with the CLI
------------------------------------------------
In case you're using the CLI to open the Hasura console, use the ``admin-secret`` flag when you open the console:
.. code-block:: bash
hasura console --admin-secret=myadminsecretkey

View File

@ -1,66 +0,0 @@
.. meta::
:description: Update Hasura GraphQL engine with Kubernetes deployment
:keywords: hasura, docs, deployment, kubernetes, update
.. _kubernetes_update:
Updating Hasura GraphQL engine running on Kubernetes
====================================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
This guide will help you update the Hasura GraphQL engine running on Kubernetes. This guide assumes that you already have
the Hasura GraphQL engine running on Kubernetes.
Step 1: Check the latest release version
----------------------------------------
The current latest version is:
.. raw:: html
<code>hasura/graphql-engine:<span class="latest-release-tag">latest</span></code>
All the versions can be found at: https://github.com/hasura/graphql-engine/releases.
Step 2: Update the container image
----------------------------------
In the ``deployment.yaml`` file, update the image tag to this latest version.
For example, if you had:
.. raw:: html
<code>
containers:<br>
- image: hasura/graphql-engine:v1.0.0-alpha01
</code>
you should change it to:
.. raw:: html
<code>
containers:<br>
- image: hasura/graphql-engine:<span class="latest-release-tag">latest</span>
</code>
Step 3: Rollout the change
--------------------------
.. code-block:: bash
$ kubectl replace -f deployment.yaml
.. note::
If you are downgrading to an older version of the GraphQL engine you might need to downgrade your metadata catalogue version
as described in :ref:`downgrade_hge`

View File

@ -20,6 +20,9 @@ Based on your deployment method, the Hasura GraphQL engine logs can be accessed
- :ref:`On Heroku <heroku_logs>`
- :ref:`On Docker <docker_logs>`
- :ref:`On Kubernetes <kubernetes_logs>`
- :ref:`On Digital Ocean <do_logs>`
- :ref:`On Azure <azure_logs>`
- :ref:`On Google Cloud & Kubernetes <gc_kubernetes_logs>`
.. _log-types:

View File

@ -21,6 +21,7 @@ access to your GraphQL endpoint and the Hasura console:
- :ref:`For Heroku <heroku_secure>`
- :ref:`For Docker <docker_secure>`
- :ref:`For Kubernetes <kubernetes_secure>`
- :ref:`For Digital Ocean <digital_ocean_secure>`
.. note::

View File

@ -22,6 +22,7 @@ Based on your deployment method, follow the appropriate guide to update the Grap
- :ref:`Updating on Heroku <heroku_update>`
- :ref:`Updating on Docker <docker_update>`
- :ref:`Updating on Kubernetes <kubernetes_update>`
- :ref:`Updating on Digital Ocean <do_updating>`
Latest available versions
-------------------------
@ -47,3 +48,4 @@ The current latest pre-release version is:
.. note::
Full stability with pre-release builds is not guaranteed. They are not recommended for production use.

View File

@ -38,8 +38,6 @@ Get started using an existing database
- `Using Hasura Cloud <https://hasura.io/docs/cloud/1.0/manual/getting-started/index.html>`__ **(recommended)**: Create a new Hasura Cloud project connected to an existing Postgres database.
- :ref:`Using Docker <deployment_docker>`: Run as a docker container and connect to an existing Postgres
database.
- :ref:`Using Heroku <heroku_existing_db>`: Run on Heroku using an existing Heroku
Postgres database.
- :ref:`Using Kubernetes <deploy_kubernetes>`: Run on Kubernetes and connect to an existing Postgres
database.

View File

@ -1,66 +0,0 @@
.. meta::
:description: Get started with Hasura using Heroku
:keywords: hasura, docs, start, heroku
.. _heroku_one_click:
One-click deployment with Heroku
================================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
Introduction
------------
This guide will help you get the Hasura GraphQL engine and Postgres running on `Heroku's free tier <https://www.heroku.com/free>`__.
It is the easiest and fastest way of trying out Hasura.
If you'd like to link this to an existing database, please head to this guide instead:
:ref:`Using an existing database on Heroku <heroku_existing_db>`.
Deploy to Heroku
----------------
Click the button below to deploy to Heroku:
.. image:: https://camo.githubusercontent.com/83b0e95b38892b49184e07ad572c94c8038323fb/68747470733a2f2f7777772e6865726f6b7563646e2e636f6d2f6465706c6f792f627574746f6e2e737667
:width: 200px
:alt: heroku_deploy_button
:class: no-shadow
:target: https://heroku.com/deploy?template=https://github.com/hasura/graphql-engine-heroku
.. note::
If you don't have an account on Heroku, you need to sign up on Heroku. You won't need a credit card, and once you
sign up you'll be redirected to your Heroku app creation page automatically.
.. thumbnail:: /img/graphql/manual/guides/heroku-app.png
:alt: Deploy to Heroku
Note that **Heroku's free Postgres add-on** is also automatically provisioned!
Open the Hasura console
-----------------------
That's it! Head to ``https://<YOUR_HEROKU_APP>.herokuapp.com`` and open your app.
You should see the Hasura console.
.. thumbnail:: /img/graphql/manual/guides/heroku-app-deployed.png
:alt: Open the Hasura console
Hello World (GraphQL or event triggers)
---------------------------------------
Make your :ref:`first graphql query <first_graphql_query>`
OR
Set up your :ref:`first event trigger <first_event_trigger>`
Advanced
--------
This was a quickstart guide to get the Hasura GraphQL engine up and running quickly. For more detailed instructions
on deploying using Heroku, check out :ref:`deploy_heroku`.

View File

@ -1,39 +0,0 @@
.. meta::
:description: Guides for deploying Hasura
:keywords: hasura, docs, guide, deployment
.. _guides_deployment:
Guides: Deployment
==================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
- `One-click deployment with Hasura Cloud <https://hasura.io/docs/cloud/1.0/manual/getting-started/index.html>`__
- :ref:`One-click deployment with Heroku <heroku_one_click>`
- :ref:`Digital Ocean One-click App on Marketplace <deploy_do_marketplace>`
- :ref:`Azure Container Instances with Postgres <deploy_azure_ci_pg>`
- :ref:`Google Cloud Platform with Kubernetes engine and Cloud SQL <deploy_gc_kubernetes>`
- :ref:`Render One-click Deploy with Managed PostgreSQL <deploy_render>`
- :ref:`Nhost One-click Deploy with Managed PostgreSQL, Storage, and Auth <deploy_nhost>`
- `Blog: Instant GraphQL on AWS RDS <https://hasura.io/blog/instant-graphql-on-aws-rds-1edfb85b5985>`__
.. note::
The above are guides to deploy the Hasura GraphQL engine on some specific platforms.
For more generic guides, see :ref:`deployment`.
.. toctree::
:maxdepth: 1
:titlesonly:
:hidden:
Heroku One-click deployment <heroku-one-click>
DigitalOcean One-click App on Marketplace <digital-ocean-one-click>
Azure Container Instances with Postgres <azure-container-instances-postgres>
Google Cloud Platform with Kubernetes engine and Cloud SQL <google-kubernetes-engine-cloud-sql>
Render One-click Deploy with managed PostgreSQL <render-one-click>
Nhost One-click Deploy with managed PostgreSQL, Storage, and Auth <nhost-one-click>

View File

@ -17,7 +17,6 @@ Guides / Tutorials / Resources
:titlesonly:
Data modelling guides <data-modelling/index>
Deployment guides <deployment/index>
Sample apps & boilerplates <sample-apps/index>
Integration/migration tutorials <integrations/index>
Integrating with monitoring frameworks <monitoring/index>