PostgreSQL Deployment with `nifectl`
This section explains how to deploy a PostgreSQL database using the nifectl CLI.
Initialize the PostgreSQL Application
Use the nifectl init command to register your PostgreSQL application and generate the required nife.toml file.
nifectl init --name your-database-name --builtin postgres --org your-organization-name --volume-size 1 --volume-path /var/lib/postgresql/data/pgdata --port 5432 --external 5432 --replica 1 --routing-policy Latency --request-memory 12 --request-cpu 0.5 --limit-memory 12 --limit-cpu 1
Explanation of Flags
--name: A unique name for your application.--builtin=postgres: Specifies the use of PostgreSQL as the runtime.--org: The organization name that will own the app.--volume-size: Size of the persistent volume in GB.--volume-path: Filesystem path inside the container (/var/lib/postgresql/data/pgdatafor PostgreSQL).--portand--external: Internal and external port (default PostgreSQL port is 5432).--request-*and--limit-*: Resource configuration for CPU and memory.--replica: Number of instances (replicas) to be deployed.--routing-policy: Defines how traffic is routed (e.g., Latency, Geolocation).
Deploy the PostgreSQL Application
Once the application is initialized, deploy it with the required environment variables using the following command:
nifectl deploy -e POSTGRES_PASSWORD=your-secret-password -e PGDATA=/var/lib/postgresql/data/pgdata/postgres
- Replace
your-secret-passwordwith a secure password of your choice. POSTGRES_PASSWORDis required by PostgreSQL to initialize the root user.PGDATAsets the database data directory.