Skip to content

Deployment review #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/content/doc-surrealdb/deployment/amazon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import DarkLogo from "@img/icon/dark/amazon.png";
<br />

## What is Amazon EKS?

[Amazon Elastic Kubernetes Service (Amazon EKS)](https://docs.aws.amazon.com/eks/) is a managed service that eliminates the need to install, operate, and maintain your own Kubernetes control plane on Amazon Web Services (AWS).
This deployment guide covers setting up a highly available SurrealDB cluster backed by [TiKV](https://tikv.org/) on Amazon EKS.

Expand Down Expand Up @@ -194,6 +195,7 @@ managedNodeGroups:
```

Based on this configuration eksctl will:

- Create a [VPC](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) across three availability zones
- Create an EKS cluster
- Create an [IAM OIDC](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html) provider
Expand Down Expand Up @@ -264,7 +266,8 @@ helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
```

## Install SurrealDB
The following script will install SurrealDB on your EKS cluster backed by TiKV with a public endpoint exposed via an Application Load Balancer (ALB)

The following script will install SurrealDB on your EKS cluster backed by TiKV with a public endpoint exposed via an Application Load Balancer (ALB).

```yaml title="INSTALL SURREALDB"
helm repo add surrealdb https://helm.surrealdb.com
Expand All @@ -287,7 +290,7 @@ helm install \
surrealdb-tikv surrealdb/surrealdb
```
## Test your SurrealDB Installation
You can get the endpoint to use with your surrealdb client as follows
You can get the endpoint to use with your SurrealDB client as follows:

```bash title="Test installation"
export SURREALDB_ENDPOINT=$(kubectl get ingress surrealdb-tikv -o json | jq '.status.loadBalancer.ingress[0].hostname' | xargs)
Expand All @@ -296,16 +299,19 @@ echo $SURREALDB_ENDPOINT
# sample output
> ingress-27v2-902764750.eu-west-1.elb.amazonaws.com
```
Test your connection with the following command

```bash title="connection test"
Test your connection with the following command:

```bash
surreal sql -e https://$SURREALDB_ENDPOINT
>
```

## Cleanup

```bash title="CLEANUP"
Cleanup can be performed with the following commands.

```
kubectl delete -f tidb-monitor.yaml -n tidb-cluster
kubectl delete -f tidb-cluster.yaml -n tidb-cluster
helm uninstall surrealdb-tikv
Expand Down
52 changes: 27 additions & 25 deletions src/content/doc-surrealdb/deployment/azure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import DarkLogo from "@img/icon/dark/azure.png";
## What is AKS?

[Azure Kubernetes Service](https://azure.microsoft.com/products/kubernetes-service) is a managed Kubernetes service offered by the Microsoft Azure platform.
This article will guide you through setting up a highly available SurrealDB cluster backed by [TiKV](https://tikv.org/) on a Azure Kubernetes Service cluster.

This article will guide you through setting up a highly available SurrealDB cluster backed by [TiKV](https://tikv.org/) on an Azure Kubernetes Service cluster.

## What is TiKV?

[TiKV](https://tikv.org/) is a cloud-native transactional key/value store built by PingCAP and that integrates well with Kubernetes thanks to their tidb-operator.
[TiKV](https://tikv.org/) is a cloud-native transactional key/value store built by PingCAP and that integrates well with Kubernetes thanks to their [TiDB operator](https://github.com/pingcap/tidb-operator).

## Prerequisites

Expand All @@ -45,7 +46,6 @@ In order for you to complete this tutorial you'll need:
> [!NOTE]
> Provisioning the environment in your Azure account will create resources and there will be cost associated with them. The cleanup section provides a guide to remove them, preventing further charges.


> [!NOTE]
> This guide was tested in <code>westeurope</code> region and it follows TiKV best practices for scalability and high availability.
This tutorial is intended for production workloads using the <code>standard</code> tier. If you want to create a dev/test environment, you should root for the <code>free</code> tier and change the cluster and node pool configuration (no zone, fewer nodes).
Expand All @@ -54,20 +54,20 @@ This tutorial is intended for production workloads using the <code>standard</cod

1. Log in to Azure and get the current subscription if you have multiple subscriptions.

```bash title="Log in to Azure and list Azure subscriptions"
```bash
$ az login
$ az account list
```

2. Create a new resource group
2. Create a new resource group:

```bash title="Create a new resource group"
```bash
$ az group create --name rg-surrealdb-aks --location westeurope
```

3. Run the following command to create a cluster:
3. Run the following command to create a new AKS cluster:

```bash title="Create a new AKS cluster"
```bash
$ az aks create \
--resource-group rg-surrealdb-aks \
--location westeurope \
Expand All @@ -82,7 +82,7 @@ $ az aks create \

4. After the creation finishes, get credentials to configure <code>kubectl</code> to connect to the new cluster:

```bash title="Get AKS cluster credentials"
```bash
$ az aks get-credentials --resource-group rg-surrealdb-aks --name surrealdb-aks-cluster
```

Expand All @@ -102,9 +102,9 @@ aks-nodepool1-33674805-vmss000002 Ready agent 2m34s v1.26.6
> [!NOTE]
> In order to speed things up, the following commands can be executed in parallel.

1. Create a TiDB Operator and monitor pool
1. Create a TiDB Operator and monitor pool:

```bash title="Create a TiDB Operator and monitor pool"
```bash
$ az aks nodepool add --name admin \
--resource-group rg-surrealdb-aks \
--cluster-name surrealdb-aks-cluster \
Expand All @@ -113,9 +113,9 @@ $ az aks nodepool add --name admin \
--labels dedicated=admin
```

2. Create a PD node pool
2. Create a PD node pool:

```bash title="Create a PD node pool"
```bash
$ az aks nodepool add --name pd \
--resource-group rg-surrealdb-aks \
--cluster-name surrealdb-aks-cluster \
Expand All @@ -126,9 +126,9 @@ $ az aks nodepool add --name pd \
--node-taints dedicated=pd:NoSchedule
```

3. Create a TiKV node pool
3. Create a TiKV node pool:

```bash title="Create a TiKV node pool"
```bash
$ az aks nodepool add --name tikv \
--resource-group rg-surrealdb-aks \
--cluster-name surrealdb-aks-cluster \
Expand All @@ -148,13 +148,13 @@ You can deploy it following these steps:

1. Install CRDS:

```bash title="Install CRDS"
```bash
$ kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.5.0/manifests/crd.yaml
```

2. Install TiDB Operator Helm chart:

```bash title="Install TiDB operator"
```bash
$ helm repo add pingcap https://charts.pingcap.org
$ helm repo update
$ helm install \
Expand Down Expand Up @@ -262,13 +262,13 @@ spec:

2. Create the TiDB cluster:

```bash title="Create TiDB cluster"
```bash
$ kubectl apply -f tikv-cluster.yaml
```

3. Check the cluster status and wait until it's ready:

```bash title="Verify TiDB cluster"
```bash
$ kubectl get tidbcluster

$ kubectl get pods
Expand All @@ -286,11 +286,11 @@ sdb-datastore-tikv-2 1/1 Running 0 3m12s
## Deploy SurrealDB

Now that we have a TiDB cluster running, we can deploy SurrealDB using the official Helm chart.
The deploy will use the latest SurrealDB Docker image and make it accessible on internet.
The deployment will use the latest SurrealDB Docker image and make it accessible on internet.

1. Get the TiKV PD service URL:

```bash title="Get TiKV PD service URL"
```bash
$ kubectl get service sdb-datastore-pd

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
Expand All @@ -301,7 +301,7 @@ $ export TIKV_URL=tikv://sdb-datastore-pd:2379

2. Install the SurrealDB Helm chart with the TIKV_URL defined above and with auth disabled so we can create the initial credentials:

```bash title="Install SurrealDB Helm chart"
```bash
$ helm repo add surrealdb https://helm.surrealdb.com
$ helm repo update
$ helm install \
Expand All @@ -326,14 +326,16 @@ surrealdb-tikv LoadBalancer 10.0.38.191 20.13.45.154 80:30378/TCP 6m34

4. Connect to the cluster and define the initial credentials:

```bash title="Define initial credentials"
```bash
$ export SURREALDB_URL=http://$(kubectl get service surrealdb-tikv -o json | jq -r .status.loadBalancer.ingress[0].ip)

$ surreal sql -e $SURREALDB_URL
> DEFINE USER root ON ROOT PASSWORD 'StrongSecretPassword!' ROLES OWNER;
```

# Verify you can connect to the database with the new credentials:
5. Verify you can connect to the database with the new credentials:

```
$ surreal sql -u root -p 'StrongSecretPassword!' -e $SURREALDB_URL
> INFO FOR ROOT
[{ accesses: { }, namespaces: { ns: 'DEFINE NAMESPACE ns' }, nodes: { "0e87c953-68d7-40e1-9090-3dfc404af25e": 'NODE 0e87c953-68d7-40e1-9090-3dfc404af25e SEEN 1742870304370 ACTIVE' }, system: { available_parallelism: 14, cpu_usage: 5.905298233032227f, load_average: [1.2802734375f, 1.5400390625f, 1.71484375f], memory_allocated: 13492047, memory_usage: 187547648, physical_cores: 14, threads: 32 }, users: { root: "DEFINE USER root ON ROOT PASSHASH '...' ROLES OWNER DURATION FOR TOKEN 1h, FOR SESSION NONE" } }]
Expand All @@ -355,7 +357,7 @@ $ helm upgrade \

## Cleanup

Run the following commands to delete the Kubernetes resources and the AKS cluster:
Run the following commands to delete the Kubernetes resources and the AKS cluster.

```bash title="Cleanup commands"
$ helm uninstall surrealdb-tikv
Expand Down
8 changes: 5 additions & 3 deletions src/content/doc-surrealdb/deployment/fly.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import DarkLogo from "@img/icon/dark/fly.png";
This document is based on a guide by one of our community members. You can find it here.

## Requirements

- [Make sure that you have `flyctl` installed](https://fly.io/docs/hands-on/install-flyctl).
- Use either [flyctl auth signup](https://fly.io/docs/hands-on/sign-up) or [flyctl auth login](https://fly.io/docs/hands-on/sign-in) to authenticate your client.

Expand All @@ -37,16 +38,17 @@ mkdir surrealdb-deployment && cd surrealdb-deployment
## Uncomment the below line for Windows
# notepad Dockerfile
```

In the `Dockerfile` we specify which base image we want to use, and to which address/port we will bind the instance. You can edit the `Dockerfile` file and paste the following snippet into the file without any indents or spaces. The rest of the SurrealDB configuration will be done later with secrets.

```bash title="Docker file"
FROM surrealdb/surrealdb:latest
EXPOSE 8080
CMD ["start", "--bind", "0.0.0.0:8080", "file://data/srdb.db"]
CMD ["start", "--bind", "0.0.0.0:8080", "rocksdb://data/srdb.db"]
```

> [!IMPORTANT]
> The `file://` prefix for starting SurrealDB will be deprecated in the next major release, we advise to please use `surrealkv://` or `rocksdb://` as a storage engine
> While still usable, the `file://` prefix for starting SurrealDB has been deprecated in favour of `surrealkv://` or `rocksdb://` as a storage engine.

## Generate fly.toml
We will generate most of the content for the `fly.toml` configuration file using the `fly launch` utility. Please answer the questions with the guidelines given below.
Expand All @@ -61,7 +63,7 @@ fly launch --no-deploy
- `Would you like to deploy now?`: No, we need to finalize our configuration first.

## Create volume for persistent storage
For this demo, we'll create a single volume with a size of 1 GB. Make sure to set it to the same region that you chose earlier! In this case data is the name of the volume.
For this demo, we'll create a single volume with a size of 1 GB. Make sure to set it to the same region that you chose earlier! In this case, `data` is the name of the volume.

```bash title="Create the volume"
fly volumes create data --region <region> --size 1
Expand Down
Loading