Connecting

SchemaHero accepts a standard Postgres uri field when connecting to a Postgres database. This connection string supports many options, and full documentation can be found here: https://github.com/go-sql-driver/mysql#dsn-data-source-name.

The syntax of a Postgres connection URI is:

postgresql://[user[:password]@][netloc][:port][,...][/dbname][?param1=value1&...]

(Note: SchemaHero also supports postgres://, in addition to the official postgresql://).

All supported parameters are documented on the Postgres website.

apiVersion: databases.schemahero.io/v1alpha3
kind: Database
metadata:
  name: my-database
spec:
  connection:
    postgres:
      uri:
        value: postgresql://username:[email protected]:5432/my-database

Alternatively, it's possible to read the URI from a Kubernetes Secret:

apiVersion: v1
kind: Secret
metadata:
  name: postgresql-secret
data:
  uri: cG9zdGdyZXNxbDovL3VzZXJuYW1lOnBhc3N3b3JkQHBvc3RncmVzOjU0MzIvbXktZGF0YWJhc2U=
---
apiVersion: databases.schemahero.io/v1alpha3
kind: Database
metadata:
  name: my-database
spec:
  connection:
    postgres:
      uri:
        valueFrom:
          secretKeyRef:
            name: postgresql-secret
            key: uri