# Enterprise Deployment Guide for GCP

Deploying RagaAI Catalyst on your Google Cloud Platform infrastructure ensures that your data remains secure and within your control. Follow these steps to set up RagaAI Catalyst in your GCP account.

1. [Provision Base Infrastructure](#provision-base-infrastructure)
2. [Installation Execution](#install-raga-catalyst)
3. [Verify Installation](#access-raga-catalyst)

## Provision Base Infrastructure

To get started quickly, you can use the Terraform Templates and scripts provided by the Raga team:

### Pre-Requirements

* **Set Up GCP User:** The user running the installation should have Owner or Editor roles along with Service Account Admin permissions.
* **Resource Quotas:** Ensure that you have sufficient quota for the VMs. At least 3 nodes, each with:
  * 4 vCPUs
  * 16 GiB RAM
* Ensure that your system supports Bash commands.
* The following CLI tools should be installed:
  * [terraform](https://developer.hashicorp.com/terraform/install)
  * [gcloud SDK](https://cloud.google.com/sdk/docs/install)
  * [python](https://www.python.org/downloads/)

### GCP Authentication using CLI

<details>

<summary>Using gcloud auth login</summary>

```bash
gcloud auth login
```

This will open a browser window for authentication.

</details>

<details>

<summary>Set GCP Environment Variables</summary>

```bash
export GOOGLE_PROJECT_ID=your-project-id
export GOOGLE_REGION=your-region
export GOOGLE_ZONE=your-zone
```

</details>

**Authenticate with the Google Cloud SDK:**

```bash
gcloud auth application-default login
```

**Validate GCP CLI Login:**

```bash
gcloud auth list
```

### Execute the following command to Provision the Environment:

Extract the TAR file provided by the RagaAI team:

```bash
tar -zxvf raga-catalyst-terraform-gcp-<version>.tar
```

`gcp-infra.sh` is the cloud provisioning script. This uses python, gcloud CLI, and terraform to provision the base infra.

```bash
bash gcp-infra.sh --region=<region> --customer-name=<customer-name> --docker-hub-pat=<docker-hub-pat> --project-id=<project_id>
```

Replace placeholders:

* `<region>`: GCP region (e.g., us-central1)
* `<customer-name>`: This will be the prefix for all GCP resources
* `<docker-hub-pat>`: Provided by RagaAI team
* `<project_id>`: Project ID (e.g., raga-poc-117209)

#### List of GCP Resources Provisioned by RagaAI Terraform Infrastructure

> Note: You can also set up your cloud environment using the following requirements as an alternative to the RagaAI Terraform templates

<details>

<summary>Cloud Storage</summary>

Create a Storage Bucket and configure CORS with the following settings:

* Allowed Methods: GET, PUT
* Allowed Origins: \* (all origins)
* Allowed Headers: \* (all headers)
* Exposed Headers: none
* Max Age: 3000 seconds

</details>

<details>

<summary>CloudSQL MySQL</summary>

* Database Version: MySQL 8.0
* CPU : 2 vCPU
* Memory: 7.5GB RAM
* Storage: 50GB

</details>

<details>

<summary>Google Kubernetes Engine (GKE)</summary>

* Kubernetes v1.24+ (Recommend container runtime)
* Ensure sufficient quota for compute resources
* **Node Pool Configuration**

  | **Node Pool**     | **VM Type**   | **vCPU & Memory** | **Min Size** | **OS Disk** | **Architecture** |
  | ----------------- | ------------- | ----------------- | ------------ | ----------- | ---------------- |
  | **AMD Node Pool** | n2-standard-4 | 4vCPU & 16GB      | 3 nodes      | 64 GB       | x86\_64          |
* **Cluster Add-ons**
  * GCE Persistent Disk CSI Driver
* **Cluster Autoscaler**
  * Enable cluster autoscaler for node pools

</details>

<details>

<summary>Network Configuration</summary>

* Create a VM in a public subnet to act as a bastion/jump box
  * Size: e2-small (2 vCPU and 2 GB Memory)
  * OS Disk: 10 GB
* Firewall Rules for bastion host
  * Inbound Rules:
    * Allow SSH (port 22)
  * Outbound Rules:
    * Allow all outbound within VPC
* Firewall Rules for internal load balancer
  * Inbound Rules:
    * Allow HTTP (port 80) from VPC
    * Allow HTTPS (port 443) from VPC
  * Outbound Rules:
    * Allow all outbound within VPC
* VPC Network with address space
* 2 Public and 2 private subnets
* Route table for private subnets
* Cloud NAT for private subnet outbound

</details>

## Install Raga Catalyst

#### Install Raga Catalyst:

* SSH into the bastion VM and run the installation command
* Configure gcloud CLI and kubectl to interact with your GKE cluster
* Copy the TAR file provided by the RagaAI team into the instance & extract the file
* Update the .env file with the values that you get when you execute the terraform output command

Execute the following command to deploy Catalyst:

```bash
python3 gcp-catalyst.py
```

Run the Database Migration

```bash
helm install db-migration db-migration \
  -n raga \
  --set ReleaseTag=<release-tag> \
  --set GcsBucketname=<gcs-bucket-name>
```

Install Raga Services

```bash
helm install raga raga \
  -n raga \
  --set ReleaseTag=<release-tag> \
  --set GcsBucketname=<gcs-bucket-name>
```

## Access Raga Catalyst

Access Catalyst UI with the private load balancer IP/DNS:

* Portal: `http://<Load_Balancer_IP>`
* API: `http://<Load_Balancer_IP>/api`

***

For any issues during the deployment process or additional assistance, please contact our support team at <contact@raga.ai>.
