Skip to main content
Version: v0.14 🚧

postgres

Schema PostgreSQL

PostgreSQL describes the attributes to locally deploy or create a cloud provider
managed postgresql database instance for the workload.

Attributes

nametypedescriptiondefault value
type required"local""cloud"Type defines whether the postgresql database is deployed locally or provided by
cloud vendor.
version requiredstrVersion defines the postgres version to use.

Examples

#Instantiate a local postgresql database with image version of 14.0. 

import postgres as postgres

accessories: {
"postgres": postgres.PostgreSQL {
type: "local"
version: "14.0"
}
}

Credentials and Connectivity

For sensitive information such as the host, username and password for the database instance, Kusion will automatically inject them into the application container for users through environment variables. The relevant environment variables are listed in the table below.

NameExplanation
KUSION_DB_HOST_<DATABASE_NAME>Host address for accessing the database instance
KUSION_DB_USERNAME_<DATABASE_NAME>Account username for accessing the database instance
KUSION_DB_PASSWORD_<DATABASE_NAME>Account password for accessing the database instance

The databaseName can be declared in workspace configs of postgres, and Kusion will automatically concatenate the <PROJECT_NAME>, <STACK_NAME>, <APP_NAME> and postgres with - if not specified. When injecting the credentials into containers' environment variables, Kusion will convert the databaseName to uppercase, and replace - with _.