Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
SilviaPedroso
Advisor
Advisor
This blog post is a series of 3, our aim is to walkthrough the set-up of your PostgreSQL service on a Kyma environment:

  1. PostgreSQL is now available on the Kyma environment (read me first)

  2. How to deploy PostgreSQL on a Kyma environment (read me second)

  3. Connect to a PostgreSQL instance on a Kyma environment (current read)


In this article we will cover how to connect to your PostgreSQL instance on the Kyma environment

Before connecting to your PostgreSQL instance there are some prerequisites and steps that need to be carried out:

  • Ensure you have carried out the steps described in blog 1 and blog 2.

  • Install kubectl (Using SAP BTP Services in the Kyma Environment), you will need this for connecting to your Kyma environment.

  • Ensure you have psql installed, you will need this to test your connection to the PostgreSQL instance, alternatively you can use a GUI tool such as pgAdmin4.

  • Ensure you have your IP address authorized for connection within your instance on the Kyma Dashboard.


In order to connect to a PostgreSQL instance you need to access the instance credentials and URI (Uniform Resource Identifier), you can extract this information from your binding.

Within your Kyma dashboard you can access the ‘URI’ and ‘Secret’ of your PostgreSQL instance. Navigate to your service binding (1) and select the service binding name hyperlink (2)Select the ‘Secret Name’ (3) where you will have the ‘URI’ and credentials to access your PostgreSQL instance.Select the decode (4) button to see the values decoded, you will need them for the following steps.

Allowing your IP address to be used for connection

To connect to your PostgreSQL your IP address needs to be added as a value to the instance parameter ‘allow-access’. Using Kyma dashboard you can navigate to your ‘Service Instance’ and select ‘Edit’.Within the ‘Instance Parameters’ section add the parameter ‘allow_access’ (string format), followed by your IP address, after selecting ‘Update’ a success message should be displayed with ‘Service Instance Updated’.

If you wish to consume a PostgreSQL instance through an application using Kyma please additionally add the Cluster NAT IPS to your ‘allow_access’ parameters.

To obtain the cluster NAP IPs please follow the guidelines provided within the following Kyma documentation.

Once you have your cluster IP address add it to the allow-access parameters within your PostgreSQL instance as you did above for your own IP.

Now that you have successfully allow listed your IP you can connect to your PostgreSQL instance.

Using psql to connect to the instance, open your terminal window (psql) and execute the below command using your decoded URI information as a parameter.

Once connected successfully, test your PostgreSQL connection by verifying your PostgreSQL instance version for example.


Your PostgreSQL version will be displayed.


 

Alternatively, you can use the GUI tool pgAdmin 4 to test your connection, for that you need to register your server.



Once connected successfully, test your PostgreSQL connection by using the query tool and verify for example the list of all databases in your PostgreSQL instance using the below SELECT statement.


Congratulations! You have now successfully connected to your PostgreSQL instance and are ready to start using it for your development.


 

Relevant sources of information: 

  • For detailed information on how to create instances on Kyma please refer to Kyma learning.

  • For additional details on Kyma set-ups please access the SAP Help portal and also have a look at the video series provided in the following Kyma Blog.

  • For more information on PostgreSQL on SAP BTP, hyperscaler option service, please check SAP Help.

  • For information on PostgreSQL pricing and commercial options and regions, please check SAP Discovery Center.


Thank you,

SAP BTP Backing Services – Product Management
13 Comments
0 Kudos

Hi Silvia,

Great article, I've followed all the steps (i get stuck at the begging due to the need to activate the BTP Operator on the kyma-system namespace ) but when i try to connect i receive time out, i've checked all the given steps (including the IP whitelisting) but i can not connect to the DB so i want to know if i need to enable some ingress rule on Kyma or some other stuff to enable the access to the Postgres DB.

Is required to follow this link?

Thanks a lot.

gabbi
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Gaurav,

Thanks a lot for your response, i've completed the steps related with adding the BTP operator and creating the Service Instance of Postgres Service and the corresponding Service Binding adding my ip to get access but unfortunately i can not get access, seems i need to add some config to enable access form my ip, i don't know if can be related with some ingress rule or network config on the kyma side or something else, Do you know what i'm missing? Do i need to stablish an SSH connection?

Thanks a lot.

Best Regards.
gabbi
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Ignacio,

Apart from what is mentioned in the blog. I do not think so.

I have asked the author to take a look.

 

BR

Gaurav
SilviaPedroso
Advisor
Advisor
0 Kudos
Hi ignacio_rubio_laina

Did you add your computer ip address to the allow_access parameter? Please consider also which computer IP address your using, as sometimes when connecting with VPN its not the computer's IP when validating on ipconfig. It's worth to confirm your online IP when using VPN.

Also if you wish to consume a PostgreSQL instance through an application using Kyma please additionally add the Cluster NAT IPS to your ‘allow_access’ parameters > Kyma documentation

Hope this helps,

Thank you,

KR,

Silvia
0 Kudos
Hi ignacio_rubio_laina,

Did you manage to connect yourself to the PostgreSQL service ?

I've the same behaviour: "Connection Time out" even if I had my IP or Cluster NAT IPs to "allow_access".
pandeysuresh06
Participant
0 Kudos
Hi @silvia.pedroso@sap.com getting connection time out when trying to connect to postgresql, just trying through the .//psql command on command prompt in windows ,getting the same error through pgadmin also. I tried adding even the cluser ID by running the get-egress-ips.ps1 to detect the region and cluster ID's.
SilviaPedroso
Advisor
Advisor
0 Kudos
Hi surepandey01,

The connection time out has been mainly related to authorization. Please check that you have provided your PC IP address in the allow access on Kyma side, ensure your using your online IP address. Check what your online IP address is to consider any VPN you might be using.

Hope this helps,

KR,

Silvia
pandeysuresh06
Participant
0 Kudos
Hi Silvia I have tested with all the ipv4 addresses which i got using the ipconfig command.
SilviaPedroso
Advisor
Advisor
0 Kudos

Hi surepandey01,

Please check your online address by searching on your internet browser 'whats my IP' as sometimes ipv4 address from ipconfig command does not give you the correct public IP.

Thank you,

KR,

Silvia

pandeysuresh06
Participant
Hi Silvia ,

 

thanks for the help, finally I am able to connect with the approach you mentioned in the last comments regarding finding the IP with browser
marcoporru
Advisor
Advisor

The allow_access looks not documented in the help portal.

additionally, it looks like this is the format for it:

 

"allow_access": "<ip-address1>,<ip-address2>,<ip-address3>"   //comma-separated list of IP addresses, semicolumn not working
maty1989
Discoverer
0 Kudos

Hello I am getting this error when I put the property allow_access.

maty1989_0-1713150087044.png

I put the property in an object like this: Any idea?

maty1989_1-1713150131241.png

Thanks a lot!