There are two methods you can use to create Power BI gateway data source connection for PostgreSQL.
PostgreSQL connector
You must install Npgsql connector with GAC in power bi gateway machine
You can the download here
https://github.com/npgsql/npgsql/releases/download/v4.0.10/Npgsql-4.0.10.msi
Once you installed, crate a source connection as shown below in Power BI service gateway. Make sure you have selected Not Encrypted in advance option, some reason encrypted option is not working.
Use the same connector in Power BI desktop development as shown below
ODBC connector
Login to Gateway server and download a required ODBC drive and install it if it wasn’t already installed. In this case using psqlodbc_x64 drive.
Create a system ODBC connection in the gateway machine
Configure the PostgreSQL credential and make sure connection is success using click on Test button.
Once your setup ODBC connection, you can create an ODBC data source in Power BI gateway as shown below. Important thing is that the dsn name should be the same as PostgreSQLCon.
Cheers!
Uma