Deploy PostgreSQL
This guide shows you how to use PostgreSQL, a powerful, open source object-relational database system.
To run it, follow these steps:
-
Install the
kraft
CLI tool and a container runtime engine, e.g. Docker. -
Clone the
examples
repository andcd
into theexamples/postgres/
directory:
Make sure to log into KraftCloud by setting your token and a metro close to you.
We use fra0
(Frankfurt, π©πͺ) in this guide:
When done, invoke the following command to deploy this application on KraftCloud:
The output shows the instance URL and other details:
In this case, the instance name is postgres-saan9
and the service group young-thunder-fbafrsxj
.
They are different for each run.
To test the deployment, first forward the port with the kraft cloud tunnel
command. Be sure to use the service group
returned by the kraft cloud deploy
command:
Now, on a separate console, you can query PostgreSQL using psql
.
We assume the username is postgres
and the password is unikraft
:
Use the unikraft
password at the password prompt.
You should see output similar to:
Use SQL and psql
commands for your work.
To disconnect, simply kill the tunnel
command with ctrl-C
At any point in time, you can list information about the instance:
When done, you can remove the instance:
Using Volumes
You can use volumes for data persistence for you PostgreSQL instance.
For that you would first create a volume:
Then start the PostgreSQL instance and mount that volume:
Customize Your Deployment
Your deployment is a standard PostgreSQL installation. Customizing the deployment generally means providing a different environment.
An obvious one is to use a different database password when starting PostgreSQL.
For that you use a different POSTGRES_PASSWORD
environment variable when starting the PostgreSQL instance.
You could also use a different port or a different location to mount your volume.
And, of course, you can use the PostgreSQL instance in conjunction with a frontend service, see the guide here.
Learn More
Use the --help
option for detailed information on using KraftCloud:
Or visit the CLI Reference.