# Prepare managed services

Create a managed PostgreSQL server for Katonic with the version, connection limit, databases and login the install checks, and know what stays in the cluster.

This stage is optional. Skip it if the platform will run its databases inside the cluster, which is the default. Use it when your policy is to run PostgreSQL as a managed service from your cloud, such as Amazon RDS, Azure Database for PostgreSQL or Cloud SQL, so that your database team patches and backs it up.

**Who can use it:** your database team creates the server and its login; your platform team puts the login into the cluster before the install. Nothing here needs a product role.

## What can be managed

| Service | At install | Notes |
| --- | --- | --- |
| PostgreSQL | Managed or in the cluster | The only data service the install configuration can point at a managed service |
| Redis | In the cluster | Installed and run by the platform |
| Object storage | Set by the platform | On premises it is the in-cluster S3-compatible store. On a cloud provider the default follows the cloud provider setting |
| Backup bucket | Always outside the cluster | Set in the backup block; see Back up and restore the platform |

Talk to Katonic before you plan a managed Redis or a managed object store of your own choosing: neither is set from the install configuration.

An air-gapped install always runs PostgreSQL, Redis and object storage in the cluster, whatever the configuration says. Skip this stage if you are air-gapped.

## Prerequisites

- The edition decided in [Plan the installation](/security/installation-journey/plan-the-installation), because it changes the databases you create.
- A network path from the cluster's nodes to the database server on its port, through any firewall or private endpoint.

## Create the server

  
**Step 1. Choose the version and size**

PostgreSQL 16. A newer major version is accepted with a warning; an older one fails the preflight.

Set `max_connections` to at least 500, or at least 1,000 on the `flagship` tier. The preflight fails below that.

  
**Step 2. Create the databases**

Create these databases before the install, owned by the login you will give the platform:

| Edition | Databases |
| --- | --- |
| AI Platform | `platform`, `knowledge_engine`, `keycloak`, `temporal`, `temporal_visibility`, `spicedb`, `mlflow` |
| AI Cloud | `keycloak` |

On AI Cloud only the shared identity database moves to the managed server. Each organisation keeps its own databases inside its own part of the cluster.

  
**Step 3. Decide how the connection is encrypted**

The connection uses TLS by default. Choose one of `require`, `verify-ca` or `verify-full`, or `disable` for a server without TLS. To verify the server's certificate, keep the certificate authority's PEM file at hand for the configuration.

  
**Step 4. Put the login in the cluster**

Create the platform namespace (`katonic`) and a secret in it holding the connection:

```bash
kubectl create namespace katonic
kubectl -n katonic create secret generic platform-db \
  --from-literal=host=DB_HOST --from-literal=port=5432 \
  --from-literal=username=DB_USER --from-literal=password='DB_PASSWORD'
```

    The secret can also carry `database`, which defaults to `platform`, and `sslmode`.

  
**Step 5. Name it in the configuration**

Add the database block to `katonic.yml` in [Check readiness](/security/installation-journey/check-readiness):

```yaml
database:
  mode: managed
  existing_secret: platform-db
  ssl_mode: verify-full
  ca_file: db-ca.pem
```

## Verify

The `postgres` check in the preflight proves it: the server is reachable from inside the cluster, TLS and the login work, the version and `max_connections` are high enough, and every database in the table exists. A database owned by a different user is reported as a warning, not a failure.

## Troubleshooting

- **The postgres check cannot connect.** The nodes have no route to the server, or a firewall or private endpoint rule is missing. Test from a pod in the cluster, not from your own workstation.
- **A database is missing.** Create it with the name exactly as listed, then run the preflight again.
- **The connection limit is too low.** Raise `max_connections` in the server's parameters and restart it if your service requires that.

## Related

- [Plan the installation](/security/installation-journey/plan-the-installation)
- [Check readiness](/security/installation-journey/check-readiness)
- Data flow and storage
- Back up and restore the platform

Source: https://docs.katonic.ai/security/installation-journey/prepare-managed-services
