By Marco Suter
Published 30th March 2022
pgAdmin is an administration and management tool for PostgreSQL. pgAdmin is an open-source and feature-rich development platform used to interact with the Postgres database sessions, in both local and remote servers. You can use pgAdmin to perform database administration required for your PostgreSQL database.
Following this guide, you will learn how to connect your PostgreSQL database on Northflank to pgAdmin.
Create a new PostgreSQL database or use an existing PostgreSQL addon you want to connect to.
For increased security, keep SSL enabled and External Access disabled. You can start with the smallest compute plan with 4 GB of storage and one replica.
After your addon is created, create a secret group and ensure the secret group is properly linked with the addon. Check the aliases:
In your project, create a new deployment service:
Under
Deployment
chooseExternal image
and set the image path todpage/pgadmin4:latest
.By adding this image path you are selecting to deploy the official pgAdmin Docker image.
Under
Environment variables
expand Runtime variables and underView
add the following:Key Value PGADMIN_DEFAULT_EMAIL
myemail@example.com PGADMIN_DEFAULT_PASSWORD
mypassword PGADMIN_LISTEN_ADDRESS
0.0.0.0
PGADMIN_LISTEN_PORT
8000
Under
Advanced
create a Secret file with mount path/pgadmin4/servers.json
and the following content:{ "Servers": { "1": { "Name": "Minimally Defined Server", "Group": "Server Group 1", "Port": 5432, "Username": "${USERNAME}", "Host": "${PG_HOST}", "SSLMode": "allow", "MaintenanceDB": "${DATABASE}" } } }
This secret file will persist the configuration so you don't need to add your PostgreSQL connection details with each restart of your service. This persistence is achieved thanks to ConfigMaps.
Under
Networking
, add Port 8000 with the HTTP protocol, and make sure it is set to public.Other ports may be detected automatically. They can be safely removed from your networking configuration.
Under
Resources
select the compute plannf-compute-50
.
This compute plan will provide your service with 0.5 vCPU and 1024 MB memory.
If a smaller compute plan is selected, start-up will take longer than expected.
Create your service,
Wait for the service to start up. pgAdmin can take a minute to initialise, so inspect the logs for the running instance to know when it is ready. Then visit the service URL displayed on the top right corner of your service to open pgAdmin.
Login with the email and password defined in your environment variables:
PGADMIN_DEFAULT_EMAIL
andPGADMIN_DEFAULT_PASSWORD
.When prompted, add your password for the PostgreSQL instance.
You are ready to manage your database!
Northflank allows you to deploy your code and databases within minutes. Sign up for a Northflank account and create a free project to get started.
- Multiple read and write replicas
- Observe & monitor with real-time metrics & logs
- Low latency and high performance
- Backup, restore and fork databases
- Private and optional public load balancing as well as Northflank local proxy
Related articles