docs: get started with kubernetes and helm

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9982
Co-authored-by: Sean Park-Ross <94021366+seanparkross@users.noreply.github.com>
GitOrigin-RevId: efaf375314f23b91b7faa32bf85083efc55e7ca4
This commit is contained in:
Toan Nguyen 2023-08-21 21:24:12 +07:00 committed by hasura-bot
parent 25b7c26ea9
commit f35372dc97
2 changed files with 221 additions and 1 deletions

View File

@ -34,6 +34,7 @@ Choose from the full list of deployment guides:
- [Deploy using Hasura Cloud](/getting-started/getting-started-cloud.mdx) (**recommended**)
- [Deploy using Docker](/deployment/deployment-guides/docker.mdx)
- [Deploy using Kubernetes](/deployment/deployment-guides/kubernetes.mdx)
- [Deploy using Kubernetes & Helm](/deployment/deployment-guides/kubernetes-helm.mdx)
- [Deploy using DigitalOcean One-click App on Marketplace](/deployment/deployment-guides/digital-ocean-one-click.mdx)
- [Deploy using Azure Container Instances with Postgres](/deployment/deployment-guides/azure-container-instances-postgres.mdx)
- [Deploy using Google Cloud Platform with Kubernetes engine and Cloud SQL](/deployment/deployment-guides/google-kubernetes-engine-cloud-sql.mdx)
@ -41,4 +42,4 @@ Choose from the full list of deployment guides:
- [Deploy using Render One-click Deploy with Managed PostgreSQL](/deployment/deployment-guides/render-one-click.mdx)
- [Deploy using Nhost One-click Deploy with Managed PostgreSQL, Storage, and Auth](/deployment/deployment-guides/nhost-one-click.mdx)
- [Deploy using Koyeb Serverless Platform](/deployment/deployment-guides/koyeb.mdx)
- [Deploy using Flightcontrol on AWS Fargate](/deployment/deployment-guides/flightcontrol.mdx)
- [Deploy using Flightcontrol on AWS Fargate](/deployment/deployment-guides/flightcontrol.mdx)

View File

@ -0,0 +1,219 @@
---
description: Easily deploy Hasura GraphQL Engine on Kubernetes using Helm Chart. This guide covers the installation of Hasura GraphQL Engine, its ecosystem, and integration with Postgres, Redis, and other essential tools for a seamless deployment experience
keywords:
- hasura graphql engine
- kubernetes deployment
- helm chart guide
- postgres integration
- hasura enterprise stack
- graphql api
- helm repository
- hasura console
- graphql query
- hasura enterprise features
sidebar_position: 5
sidebar_label: Using Kubernetes & Helm
---
import Thumbnail from '@site/src/components/Thumbnail';
import LatestRelease from '@site/src/components/LatestRelease';
# Deploy Hasura GraphQL Engine on Kubernetes with Helm Chart
To help you easily install Hasura GraphQL Engine on Kubernetes, we're happy to provide a
[Helm Chart repository](https://github.com/hasura/helm-charts) with GraphQL Engine and its ecosystem, including:
- [GraphQL Engine](https://github.com/hasura/helm-charts/tree/main/charts/graphql-engine): the chart deploys the
GraphQL Engine service with a Postgres instance for metadata storage.
- [Hasura Enterprise Stack](https://github.com/hasura/helm-charts/tree/main/charts/hasura-enterprise-stack): the
complete end-to-end Hasura GraphQL Engine Enterprise ecosystem with Redis, Observability, Dex (SSO middleware), and
Data Connectors.
In this guide, you will get up and running quickly with the Hasura GraphQL Engine and a Postgres database on Kubernetes
using Helm Chart.
### Prerequisites
- A working [Kubernetes v1.18+ cluster](https://kubernetes.io/docs/setup/production-environment/)
- [Helm v3 installed](https://helm.sh/docs/intro/install/) on your machine.
- [Kubectl installed](https://kubernetes.io/docs/tasks/tools/) and configured to be able to connect to the Kubernetes
cluster.
### Step 1: Configure a Hasura Helm repository
Run this command to add Hasura Helm repository:
```bash
helm repo add hasura https://hasura.github.io/helm-charts
```
### Step 2: Install the Helm Chart
Run the following command to install both the Hasura GraphQL Engine and a Postgres database. We assume that the release
name is `hasura` and the admin secret is `hasura`:
```bash
helm install hasura --set secret.adminSecret=hasura hasura/graphql-engine
```
:::info Keep your admin secret strong and safe
Remember to set strong admin secrets before going live.
:::
After the GraphQL Engine Helm Chart was installed successfully, print Kubernetes pods with `kubectl` to verify.
```bash
NAME READY STATUS RESTARTS AGE
hasura-graphql-engine-6cc69694dd-r4dnh 1/1 Running 1 (75s ago) 2m58s
hasura-postgres-5fd95db548-f4vhg 1/1 Running 0 2m58s
```
By default, the Helm Chart doesn't enable ingress. You need to enable port-forwarding on the `graphql-engine` pod to
localhost.
```bash
kubectl port-forward hasura-graphql-engine-6cc69694dd-r4dnh 8080:8080
```
:::info Hasura ships with a Postgres database
**Hasura relies on a Postgres database to store its metadata**, and this database can also be used to store your
application data.
If you'd like to connect another type of database for storing application data, check out our list of
[supported databases](/databases/overview.mdx).
:::
Open the Hasura Console by navigating to `http://localhost:8080/console`.
### Step 3: Try out Hasura
#### Create a table and insert some demo data
On the Hasura Console, navigate to `Data -> Create table` and create a sample table called `profiles` with the following
columns:
```sql
profiles (
id SERIAL PRIMARY KEY, -- serial -> auto-incrementing integer
name TEXT
)
```
<Thumbnail
src="/img/getting-started/create-profile-table.png"
alt="Create a table"
width="1200px"
/>
Now, insert some sample data into the table using the `Insert Row` tab of the `profiles` table.
#### Try out a query
Head to the `API` tab in the Console and try running the following query:
```graphql
query {
profiles {
id
name
}
}
```
You'll see that you get all the inserted data!
<Thumbnail
src="/img/getting-started/profile-query.png"
alt="Try out a query"
width="1200px"
/>
### Enable GraphQL Engine Enterprise
You can set the Enterprise License Key value when installing the Helm chart to enable Enterprise features.
```bash
helm install hasura --set secret.adminSecret=hasura --set secret.eeLicenseKey=<license-key> hasura/graphql-engine
```
### Advanced configuration
You can see full configuration values at
[the Github repository](https://github.com/hasura/helm-charts/blob/main/charts/graphql-engine/values.yaml) and
[example values](https://github.com/hasura/helm-charts/tree/main/charts/graphql-engine/examples) to get started.
## Hasura Enterprise Stack
If you intend to install the all-in-one deployment stack with Hasura Enterprise and its ecosystem you can try the
[hasura-enterprise-stack](https://github.com/hasura/helm-charts/tree/main/charts/hasura-enterprise-stack) Helm Chart.
The Helm Chart is a collection of sub-charts that includes:
- GraphQL Engine Helm Chart.
- [Bitnami Redis(R)](https://github.com/bitnami/charts/tree/main/bitnami/redis) for caching and rate limit.
- [Kube Prometheus Stack](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) for observability.
- [Jeager](https://github.com/jaegertracing/helm-charts) for trace collector.
- [Dex](https://github.com/dexidp/helm-charts/tree/master/charts/dex) for
[Single Sign-on middleware](https://hasura.io/docs/latest/enterprise/sso/config/#other-protocols).
- Data connector Helm Charts (GraphQL, Mongo, etc...).
Those sub-charts are disabled by default. You can enable desired charts only.
### Prerequisites
- A working Kubernetes v1.18+ cluster
- [Helm v3 installed](https://helm.sh/docs/intro/install/) on your machine.
- [Kubectl installed](https://kubernetes.io/docs/tasks/tools/) and configured to be able to connect the Kubernetes cluster.
### Step 1: Configure Hasura Helm repository
Run this command to add Hasura Helm repository:
```bash
helm repo add hasura https://hasura.github.io/helm-charts
```
### Step 2: Install the helm chart
By default, the Helm Chart will start with the basic GraphQL Engine chart above. In this guide, we will enable Hasura
Enterprise with a Redis cache.
Create an extended `values.yaml` file locally with the following values:
```yaml
global:
redis:
enabled: true
password: redispassword
graphql-engine:
secret:
adminSecret: 'hasura'
eeLicenseKey: '<set your license key here>'
```
Then install the Helm Chart with the file.
```bash
helm install hasura -f ./values.yaml hasura/hasura-enterprise-stack
```
After the Helm Chart was installed successfully, print Kubernetes pods with `kubectl` to verify.
```bash
NAME READY STATUS RESTARTS AGE
hasura-graphql-engine-65d75f997f-pkwj9 1/1 Running 0 11s
hasura-postgres-5fd95db548-6x844 1/1 Running 0 11s
hasura-redis-master-0 1/1 Running 0 11s
hasura-redis-replicas-0 1/1 Running 0 11s
```
### Advanced configuration
You can see full configuration values at
[the Github repository](https://github.com/hasura/helm-charts/blob/main/charts/hasura-enterprise-stack/values.yaml) and
[example values](https://github.com/hasura/helm-charts/tree/main/charts/hasura-enterprise-stack/examples) to get
started.