# Cloud-Provider Database

Kloudfuse uses a Postgres database for storing data. By default, a postgresql server is bundled with Kloudfuse. However, there are certain situations where the database needs to be installed outside of the Kubernetes cluster.

- **Compliance**: For certain environments, compliance requires that a database reside on a secured server.
- **Corporate Policy**: Some organizations require that databases be consolidated for ease of backup and administration.
- **Multi-Zone Availability**: If a cluster needs to be supported across AZs or Regions the database must be accessible outside the immediate cluster.

## Setup Cloud Database

### Minimum Requirements

- Version 14+
- 2 Cores
- 2GB of Memory
- 50GB Diskspace

### Google Cloud Provider (GCP)

Click the link to get started with [Google Cloud Databases](https://console.cloud.google.com/databases)

### Amazon Web Services (AWS)

Click the link to get started with [AWS RDS for Postgres](https://aws.amazon.com/rds/postgresql)

### Microsoft Azure

Click the link to get started with [Azure Database for PostgreSQL](https://azure.microsoft.com/en-us/products/postgresql)

## Database Credentials

When creating the database:

- The Username will be postgres
- The Account privileges will need to be admin
- The password can be configured by you

It requires Admin privileges not just for reading/writing but also managing database and table schemas.

Create a Kubernetes secret **kfuse-pg-credentials** by running the command below.

**NOTE:** Replace YOUR_PASSWORD with the actual password you intend to use. Be cognizant of how your shell handles special characters.

```console
export PG_CREDENTIAL="YOUR_PASSWORD"
kubectl create secret generic kfuse-pg-credentials \
  --from-literal=postgres-password="$PG_CREDENTIAL" \
  --from-literal=postgresql-password="$PG_CREDENTIAL" \
  --from-literal=postgresql-replication-password="$PG_CREDENTIAL"
unset PG_CREDENTIAL
```

## Configure Helm Chart

Update the **custom-values.yaml** with the following parameters

```yaml
installKfusePgCredentials: false

global:
  configDB:
    host: <HOST DATABASE DNS>
  orchestratorDB:
    host: <HOST DATABASE DNS>

kfuse-configdb:
  enabled: false

ingester:
  postgresql:
    enabled: false
```

Apply these changes via helm. To verify that it is working:

- You should not see a kfuse-configdb pod
- The ingester pods will be in a running state
- The az-service pods will be in a running state

This might take a few minutes, however if either ingester or az-service is encountering problems, you should check the pods logs to see what errors it is encountering.
