diff --git a/README.md b/README.md index cd2b921..db29f13 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,10 @@ To learn more about SubQuery, [see their docs](https://academy.subquery.network) - [2. Generate types](#2-generate-types) - [3. Run](#3-run) - [Localnet ONLY](#localnet-only) - - [4.1 Debugging, errors running \& building](#41-debugging-errors-running--building) - - [4.2 Using a pre-built image](#42-using-a-pre-built-image) - - [4.3 Available Scripts breakdown](#43-available-scripts-breakdown) + - [3.1 Debugging, errors running \& building](#31-debugging-errors-running--building) + - [3.2 Using a pre-built image](#32-using-a-pre-built-image) + - [3.3 Available Scripts breakdown](#33-available-scripts-breakdown) + - [3.4 Using k8s](#34-using-k8s) ## Usage & Query Docs @@ -214,7 +215,7 @@ Or Stop & clean up (delete postgres data): yarn run docker:clean:development ``` -#### 4.1 Debugging, errors running & building +#### 3.1 Debugging, errors running & building If you're hitting errors with the above command, do a nuclear clean of all potential issues: @@ -226,7 +227,7 @@ docker context use default Now pick up from the `yarn run docker:build` step above. -#### 4.2 Using a pre-built image +#### 3.2 Using a pre-built image If you are unable to build locally, a pre-built image is available on Docker Hub: [bryanchriswhite/pocketdex-subquery-node:latest](https://hub.docker.com/r/bryanchriswhite/pocketdex-subquery-node). @@ -251,7 +252,7 @@ services: ... ``` -#### 4.3 Available Scripts breakdown +#### 3.3 Available Scripts breakdown * `preinstall` - Enforces the use of Yarn as the package manager. * `postinstall` - Executes the `env:prepare` script after the installation process. @@ -278,3 +279,7 @@ services: * `docker:ps:` - Shows the status of services for the specified environment. * `docker:stop:` - Stops all active services for the specified environment without removing them. * `docker:clean:` - Stops and removes all services, volumes, and networks for the specified environment. + +#### 3.4 Using k8s + +See the instructions in [docs/kubernetes.md](./docs/kubernetes.md) for deploying using Kubernetes. \ No newline at end of file diff --git a/docs/kubernetes.md b/docs/kubernetes.md index b905c4b..9f43ab3 100644 --- a/docs/kubernetes.md +++ b/docs/kubernetes.md @@ -1,20 +1,32 @@ -### Requirements +# Local Kubernetes Deployment -1. **Kubernetes Cluster** - * If you are already running Shannon in `Localnet`, you can work with it. -2. **Helm** & **PostgreSQL** (optional if you already have PostgreSQL) +- [Requirements](#requirements) +- [Deploy it](#deploy-it) + - [1. \[Optional\] Set Up PostgreSQL](#1-optional-set-up-postgresql) + - [2. Update Database Secrets](#2-update-database-secrets) + - [3. Configure the Application](#3-configure-the-application) + - [4. Deploy Indexer and Query Components](#4-deploy-indexer-and-query-components) + - [Explore Locally](#explore-locally) + - [Expose Publically](#expose-publically) + - [Watch the Logs](#watch-the-logs) -### Deploy it: +## Requirements -**NOTE:** Before proceeding, ensure that the Kubernetes deployment has access to the PocketDex image. -You can build the image by following the instructions in the README.md file. -Then, either load it into your Kubernetes cluster using `kind local docker-images `(if you're using it) or -push it to your preferred container registry. +1. **Kubernetes Cluster**; if you are already running Shannon in `Localnet`, you can work with it. +1. **Helm** & **PostgreSQL**; optional if you already have PostgreSQL -#### 1. (Optional) Set Up PostgreSQL: +## Deploy it -If you need to deploy PostgreSQL, add the Bitnami Helm repository and install PostgreSQL. Skip this step if you already -have a PostgreSQL instance running. +**NOTE**: Before proceeding, ensure that the Kubernetes deployment has access to the Pocketdex image. You can build the image by following the instructions in the main [README](../README.md) file. + +Then, do one of the following: + +1. Load it into your Kubernetes cluster using `kind local docker-images `(if you're using it) +2. Push it to your preferred container registry + +### 1. [Optional] Set Up PostgreSQL + +**NOTE**: Skip this step if you already have a PostgreSQL instance running. Add the Bitnami Helm repository: @@ -22,22 +34,25 @@ Add the Bitnami Helm repository: helm repo add bitnami https://charts.bitnami.com/bitnami ``` +Replace all the `CHANGEME` placeholders in `kubernetes/postgresql-values.yaml`. + Install PostgreSQL: -Replace all the `CHANGEME` placeholders in `kubernetes/postgresql-values.yaml` and then run: ```shell helm install postgresql bitnami/postgresql --version 15.5.23 -f kubernetes/postgresql-values.yaml ``` -#### 2. Update Database Secrets: +#### 2. Update Database Secrets + +Replace all the `CHANGEME` placeholders in `kubernetes/db-secrets.yaml`. -Replace `CHANGEME` placeholders in `kubernetes/db-secrets.yaml` and deploy them: +Deploy them using: ```shell kubectl apply -f kubernetes/db-secrets.yaml ``` -#### 3. Configure the Application: +#### 3. Configure the Application Review/Edit and deploy the ConfigMap found in `kubernetes/configmap.yaml`: @@ -45,7 +60,7 @@ Review/Edit and deploy the ConfigMap found in `kubernetes/configmap.yaml`: kubectl apply -f kubernetes/configmap.yaml ``` -#### 4. Deploy Indexer and Query Components: +#### 4. Deploy Indexer and Query Components Create the indexer deployment and service: @@ -59,7 +74,7 @@ Create the query deployment and service: kubectl apply -f kubernetes/query-deployment.yaml ``` -### Explore Locally: +### Explore Locally To explore the application locally, you can access the query playground using a simple `port-forward`: @@ -69,24 +84,25 @@ kubectl port-forward svc/pocketdex-query --address 127.0.0.1 3000:3000 Navigate to `http://localhost:3000`, and you should see the GraphQL Playground. -### Expose to the World: +### Expose Publically -If you need to permanently expose this to the world, you will need an Ingress Controller like: +If you need to permanently expose this to the world, you will need an Ingress controller. +Any Ingress controller should work, but here are a few popular ones: -* [HAProxy Ingress](https://artifacthub.io/packages/helm/haproxy-ingress/haproxy-ingress) -* [NGINX Ingress](https://artifacthub.io/packages/helm/nginx-ingress-chart/nginx-ingress) +- [HAProxy Ingress](https://artifacthub.io/packages/helm/haproxy-ingress/haproxy-ingress) +- [NGINX Ingress](https://artifacthub.io/packages/helm/nginx-ingress-chart/nginx-ingress) -Or any other ingress controller of your choice. Once the ingress controller is set up, you can use the example Ingress configuration located at `kubernetes/ingress.yaml`. -Please note, this file is just an example. You should review and edit it as needed before deploying it. + +**NOTE**: This file is just an example. You should review and edit it as needed before deploying it. If you need TLS support, ensure your Ingress Controller is configured to handle it in front of the query service. ```shell kubectl apply -f kubernetes/ingress.yaml ``` -### Watch the Logs: +### Watch the Logs To watch the logs for both the Indexer and Query components: