Skip to main content

Configuring an External PostgreSQL Instance

If needed, you can configure AtScale to use an external instance of the PostgreSQL database it uses for data storage. This can be done before or after installing AtScale.

To configure AtScale to use an external PostgreSQL instance:

  1. Create a new PostgreSQL instance.

  2. Connect to the new PostgreSQL instance and create the following users and schemas:

    1. Create an atscale_metadata user and corresponding schema:

      CREATE DATABASE pgwire;
      \c pgwire;
      CREATE USER atscale_metadata WITH LOGIN PASSWORD 'xxxxxxx';
      GRANT ALL PRIVILEGES ON DATABASE pgwire TO atscale_metadata;
      ALTER DATABASE pgwire OWNER TO atscale_metadata;
      SET ROLE atscale_metadata;
    2. Create a keycloak user and corresponding schema:

      CREATE DATABASE keycloak;
      \c keycloak;
      CREATE USER keycloak WITH LOGIN PASSWORD 'xxxxxxxxx';
      GRANT ALL PRIVILEGES ON DATABASE keycloak TO keycloak;
      ALTER DATABASE keycloak OWNER TO keycloak;
      SET ROLE keycloak;
    3. Create an atscale user and corresponding schema:

      CREATE DATABASE atscale;
      \c atscale;
      CREATE USER atscale WITH LOGIN PASSWORD 'xxxxxxx';
      GRANT ALL PRIVILEGES ON DATABASE atscale TO atscale;
      ALTER DATABASE atscale OWNER TO atscale;
      SET ROLE atscale;
      CREATE SCHEMA IF NOT EXISTS atscale;
      CREATE SCHEMA IF NOT EXISTS modeler_backend;
      CREATE SCHEMA IF NOT EXISTS engine_settings;
      CREATE SCHEMA IF NOT EXISTS engine;
      CREATE SCHEMA IF NOT EXISTS api;
  3. On your Kubernetes cluster, create a new secret file as shown below. Be sure to replace the namespace values with the namespace in which AtScale is or will be installed, and the host, port, and password values with those appropriate for your system.

    apiVersion: v1
    kind: Secret
    metadata:
    name: keycloak-postgres-external
    namespace: atscale
    type: Opaque
    stringData:
    host: xxxx
    port: "xxxx"
    user: keycloak
    password: "xxxx"
    database: keycloak
    ---
    apiVersion: v1
    kind: Secret
    metadata:
    name: atscale-postgres-external
    namespace: atscale
    type: Opaque
    stringData:
    host: xxxx
    port: "xxxx"
    user: atscale
    password: "xxxx"
    database: atscale
    ---
    apiVersion: v1
    kind: Secret
    metadata:
    name: pgwire-postgres-external
    namespace: atscale
    type: Opaque
    stringData:
    host: xxxx
    port: "xxxx"
    user: atscale_metadata
    password: "xxxx"
    database: pgwire
  4. Apply the new secret. This creates three additional secrets: atscale-postgres-external, keycloak-postgres-external, and pgwire-postgres-external.

    kubectl apply -f filename -n namespace

    Where filename is the name of the secret file you created above, and namespace is the namespace in which AtScale is or will be installed.

  5. Make the following changes to AtScale's values.yaml file (or your values override file, if you created one).

    These changes disable the default PostgreSQL database installed with AtScale and point the AtScale services to the new secrets. This step is important because the default versions of the atscale-postgres, keycloak-postgres, and pgwire-postgres secrets will be removed in the next step.

    postgres: 
    enabled: false

    atscale-engine:
    externalDatabase:
    existingSecret: "atscale-postgres-external"
    existingSecretHostKey: "host"
    existingSecretPortKey: "port"
    existingSecretUserKey: "user"
    existingSecretPasswordKey: "password"
    existingSecretDatabaseKey: "database"

    externalPgwire:
    existingSecret: "pgwire-postgres-external"
    existingSecretHostKey: "host"
    existingSecretPortKey: "port"
    existingSecretUserKey: "user"
    existingSecretPasswordKey: "password"
    existingSecretDatabaseKey: "database"

    atscale-api:
    externalDatabase:
    existingSecret: "atscale-postgres-external"
    existingSecretHostKey: "host"
    existingSecretPortKey: "port"
    existingSecretUserKey: "user"
    existingSecretPasswordKey: "password"
    existingSecretDatabaseKey: "database"

    atscale-entitlement:
    externalDatabase:
    existingSecret: "atscale-postgres-external"
    existingSecretHostKey: "host"
    existingSecretPortKey: "port"
    existingSecretUserKey: "user"
    existingSecretDatabaseKey: "database"
    existingSecretPasswordKey: "password"

    keycloak:
    externalDatabase:
    existingSecret: "keycloak-postgres-external"
    existingSecretHostKey: "host"
    existingSecretPortKey: "port"
    existingSecretUserKey: "user"
    existingSecretDatabaseKey: "database"
    existingSecretPasswordKey: "password"
  6. If you have not yet installed AtScale, continue on with the installation procedure.

    If you have already installed AtScale, apply the updated values file:

    helm upgrade atscale oci://docker.io/atscaleinc/atscale --version version_number -n namespace -f values_file

    Where version_number is the version of AtScale you're currently on, namespace is the namespace in which AtScale is installed, and values_file is your updated values file.

  7. Restart the AtScale services to apply the new secrets.