Skip to content

Video walkthrough

Go from ZERO to Postgres SaaS in 5 minutes

Watch the video

In the above video, we covered a few basics how to:

  • Build, Access, Operate concepts
  • Build from compose spec
  • Parse sample compose configuration for a Postgres SaaS
  • Deploy in Omnistrate hosted mode
  • Activating logs and metrics integrations

Here is the configuration used:

version: "3"
x-omnistrate-my-account: # Change this to x-omnistrate-byoa if you want to deploy into your customers' account
  AwsAccountId: '' # This is your AWS account where we can deploy the management software
  AwsBootstrapRoleAccountArn: '' # This is the role that you get from the account-setup script above
  GcpProjectId: '' # You can skip GCP if you want to start with AWS or add GCP details
  GcpProjectNumber: ''
  GcpServiceAccountEmail: ''
x-omnistrate-integrations:
  - omnistrateLogging
  - omnistrateMetrics
services:
  PGAdmin:
    image: omnistrate/pgadmin4:7.5
    ports:
      - 80:80
    volumes:
      - ./data:/var/lib/pgadmin
    x-omnistrate-compute:
      instanceTypes:
        - name: t4g.small
          cloudProvider: aws
        - name: e2-medium
          cloudProvider: gcp
    x-omnistrate-capabilities:
      autoscaling:
        minReplicas: 1
        maxReplicas: 10
      httpReverseProxy:
        targetPort: 80
      enableMultiZone: true
      enableEndpointPerReplica: true
    environment:
      - DB_ENDPOINT= Writer
      - SECURITY_CONTEXT_FS_GROUP=0
      - SECURITY_CONTEXT_USER_ID=0
      - SECURITY_CONTEXT_GROUP_ID=0
      - PGADMIN_DEFAULT_EMAIL=$var.email
      - PGADMIN_SERVER_JSON_FILE=/tmp/servers.json
      - PGADMIN_DEFAULT_PASSWORD=$var.password
      - DB_USERNAME=$var.dbUser
    x-omnistrate-api-params:
      - key: email
        description: PGAdmin Email Address
        name: Email
        type: String
        export: true
        required: true
        modifiable: false
      - key: password
        description: PGAdmin Password
        name: Password
        type: String
        export: false
        required: true
        modifiable: false
      - key: dbUser
        description: Default DB Username
        name: DB Username
        type: String
        modifiable: false
        required: true
        export: true
      - key: instanceType
        description: Instance Type for the PGAdmin cluster
        name: Instance Type
        type: String
        modifiable: true
        required: true
        export: true
    x-omnistrate-mode-internal: true
  Writer:
    image: 'bitnami/postgresql:latest'
    ports:
      - 5432:5432
    volumes:
      - ./data:/var/lib/postgresql/data
    x-omnistrate-compute:
      instanceTypes:
        - cloudProvider: aws
          apiParam: writerInstanceType
        - cloudProvider: gcp
          apiParam: writerInstanceType
    x-omnistrate-capabilities:
      enableEndpointPerReplica: true
    environment:
      - POSTGRESQL_PASSWORD=$var.postgresqlPassword
      - POSTGRESQL_DATABASE=$var.postgresqlDatabase
      - POSTGRESQL_USERNAME=$var.postgresqlUsername
      - POSTGRESQL_POSTGRES_PASSWORD=$var.postgresqlRootPassword
      - POSTGRESQL_PGAUDIT_LOG=READ,WRITE
      - POSTGRESQL_LOG_HOSTNAME=true
      - POSTGRESQL_REPLICATION_MODE=master
      - POSTGRESQL_REPLICATION_USER=repl_user
      - POSTGRESQL_REPLICATION_PASSWORD=repl_password
      - POSTGRESQL_DATA_DIR=/var/lib/postgresql/data/dbdata
      - SECURITY_CONTEXT_USER_ID=1001
      - SECURITY_CONTEXT_FS_GROUP=1001
      - SECURITY_CONTEXT_GROUP_ID=0
    x-omnistrate-api-params:
      - key: writerInstanceType
        description: Writer Instance Type
        name: Writer Instance Type
        type: String
        modifiable: true
        required: true
        export: true
      - key: postgresqlPassword
        description: Default DB Password
        name: Password
        type: String
        modifiable: false
        required: true
        export: false
      - key: postgresqlDatabase
        description: Default DB Name
        name: Default Database
        type: String
        modifiable: false
        required: true
        export: true
      - key: postgresqlUsername
        description: Username
        name: Default DB Username
        type: String
        modifiable: false
        required: true
        export: true
      - key: postgresqlRootPassword
        description: Root Password
        name: Root DB Password
        type: String
        modifiable: false
        required: false
        export: false
        defaultValue: rootpassword12345
    x-omnistrate-mode-internal: true
  Reader:
    image: 'bitnami/postgresql:latest'
    ports:
      - 5433:5432
    volumes:
      - ./data:/var/lib/postgresql/data
    x-omnistrate-compute:
      instanceTypes:
        - cloudProvider: aws
          apiParam: readerInstanceType
        - cloudProvider: gcp
          apiParam: readerInstanceType
    x-omnistrate-capabilities:
      enableMultiZone: true
      enableEndpointPerReplica: true
    environment:
      - POSTGRESQL_PASSWORD=$var.postgresqlPassword
      - POSTGRESQL_MASTER_HOST=Writer
      - POSTGRESQL_PGAUDIT_LOG=READ,WRITE
      - POSTGRESQL_LOG_HOSTNAME=true
      - POSTGRESQL_REPLICATION_MODE=slave
      - POSTGRESQL_REPLICATION_USER=repl_user
      - POSTGRESQL_REPLICATION_PASSWORD=repl_password
      - POSTGRESQL_MASTER_PORT_NUMBER=5432
      - POSTGRESQL_DATA_DIR=/var/lib/postgresql/data/dbdata
      - SECURITY_CONTEXT_USER_ID=1001
      - SECURITY_CONTEXT_FS_GROUP=1001
      - SECURITY_CONTEXT_GROUP_ID=0
    x-omnistrate-api-params:
      - key: readerInstanceType
        description: Reader Instance Type
        name: Reader Instance Type
        type: String
        modifiable: true
        required: true
        export: true
      - key: postgresqlPassword
        description: Default DB Password
        name: Password
        type: String
        modifiable: false
        required: true
        export: false
      - key: postgresqlUsername
        description: Username
        name: Default DB Username
        type: String
        modifiable: false
        required: true
        export: true
    x-omnistrate-mode-internal: true
  Cluster:
    image: omnistrate/noop
    x-omnistrate-api-params:
      - key: instanceType
        description: Instance Type
        name: Instance Type
        type: String
        modifiable: true
        required: true
        export: true
        defaultValue: t4g.small
        parameterDependencyMap:
          Writer: writerInstanceType
          Reader: readerInstanceType
          PGAdmin: instanceType
      - key: postgresqlPassword
        description: Default DB Password
        name: Password
        type: String
        modifiable: false
        required: true
        export: false
        parameterDependencyMap:
          Writer: postgresqlPassword
          Reader: postgresqlPassword
          PGAdmin: password
      - key: postgresqlUsername
        description: Username
        name: Default DB Username
        type: String
        modifiable: false
        required: true
        export: true
        parameterDependencyMap:
          Writer: postgresqlUsername
          Reader: postgresqlUsername
          PGAdmin: dbUser
      - key: pgadminEmailAddress
        description: PGAdmin Email Address
        name: PGAdmin Email Address
        type: String
        modifiable: false
        required: true
        export: true
        parameterDependencyMap:
          PGAdmin: email
      - key: dbName
        description: Default Database Name
        name: Default Database
        type: String
        modifiable: false
        required: true
        export: true
        parameterDependencyMap:
          Writer: postgresqlDatabase
    depends_on:
      - Writer
      - Reader
      - PGAdmin
    x-omnistrate-mode-internal: false

Next steps

If you feeling adventurous and want to create postgres with serverless, please see this