The page has been translated by Gen AI.

Connect to DB server

Scenario Overview

PostgreSQL(DBaaS) server connection scenario involves creating a Bastion host(Virtual Server) and a Database service, and accessing the DB service through the Bastion host. To reliably connect to PostgreSQL (DBaaS) in the Samsung Cloud Platform environment, you need to create a Bastion host and establish a network connection using it. To maintain stability and a high level of security, we recommend configuring the Database service in a Private Subnet environment and setting up the Bastion host in a restricted Public Subnet environment.

This scenario primarily describes creating a Bastion host and Database service, configuring the network environment for Bastion host and Database access, and connecting through a DB client.

Architecture
Figure. PostgreSQL(DBaaS) server connection architecture

Scenario components

You can build the scenario using the following services.

Service group
service
Detailed description
NetworkingVPCA service that provides an isolated virtual network in a cloud environment
NetworkingVPC > SubnetA service that lets users segment the network within a VPC to match their purpose and scale
NetworkingVPC > Public IPA service that reserves a public IP and allocates and releases it to Compute resources.
NetworkingVPC > Internet GatewayA service that connects VPC resources to the Internet
NetworkingSecurity GroupVirtual firewall that controls server traffic
DatabasePostgreSQL(DBaaS)A service that easily creates and manages EPAS in a web environment.
ComputeVirtual ServerVirtual server optimized for cloud computing
ComputeVirtual Server > KeypairEncryption file used to connect to the Virtual Server
Table. Scenario component list
Reference
  • Since the default policy of the Security Group is Deny All, you must register only the allowed IPs.
  • The All Open(Any IP, Any Port) policy for In/Outbound can expose cloud resources directly to external threats.
    • By specifying the required IP and Port and setting a policy, you can strengthen security.

Scenario setup method

Create the services needed to build the scenario by following the procedure below.

1. ## Configure Network

Describes the process of configuring the network environment for accessing the Bastion Host and Database services.

1-1. ### Create VPC

For detailed creation instructions, refer to the Networking > VPC > How-to guides guide.
  1. All Services > Networking > VPC Click the menu. 1. Navigate to the VPC’s Service Home page.
  2. On the Service Home page, click the Create VPC button. 2. Go to the Create VPC page.
  3. On the VPC creation page, enter the information required to create the service.
    • Enter the IP range as 192.168.x.0/16.
  4. Summary Check the detailed information and estimated billing amount generated in the panel, and click the Complete button.
    • When creation is complete, check the created resources on the VPC List page.

1-2. ### Create Subnet

For detailed creation instructions, refer to the Networking > VPC > How-to guides > Subnet guide.
  1. All Services > Networking > VPC Click the menu. 1. Navigate to the VPC’s Service Home page.
  2. On the Service Home page, click the Subnet menu. 2. Navigate to the Subnet list page.
  3. Create Subnet Click the button. 3. Go to the Subnet Creation page.
  4. On the Subnet Creation page, enter the information required to create the service.
    • Select the Subnet type as General.
    • Select a pre‑created VPC.
    • Enter the IP range as 192.168.x.0/24.
  5. Summary Check the detailed information and estimated billing amount generated in the panel, and click the Complete button.
    • After creation is complete, check the created resources on the Subnet List page.

1-3. ### Create Internet Gateway

For detailed creation steps, refer to the Networking > VPC > How-to guides > Internet Gateway guide.
  1. All Services > Networking > VPC Click the menu. 1. Navigate to the VPC’s Service Home page.
  2. On the Service Home page, click the Internet Gateway menu. 2. Internet Gateway List Navigate to the page.
  3. Internet Gateway creation Click the button. 3. Navigate to the Create Internet Gateway page.
  4. On the Internet Gateway Creation page, enter the required information needed to create the service.
    • Select a pre‑created VPC.
    • In the Firewall usage option, select Use.
  5. Summary Check the detailed information and estimated billing amount generated in the panel, and click the Complete button.
    • Once creation is complete, check the created resource on the Internet Gateway List page.

1-4. ### Create Public IP

For detailed creation instructions, refer to the Networking > VPC > How-to guides > Public IP guide.
  1. All Services > Networking > VPC Click the menu. 1. Navigate to the VPC’s Service Home page.
  2. On the Service Home page, click the Public IP menu. 2. Go to the Public IP List page.
  3. Public IP reservation Click the button. 3. Go to the Public IP reservation page.
  4. On the Public IP reservation page, enter the required information for service reservation.
  5. Summary Check the detailed information and estimated billing amount generated in the panel, and click the Complete button.
    • After creation is complete, check the created resources on the Public IP List page.

1-5. ### Create Security Group

For detailed creation instructions, refer to the Networking > Security Group > How-to guides guide.
  1. Click the All Services > Networking > Security Group menu. 1. Go to the Service Home page of the Security Group.
  2. On the Service Home page, click the Create Security Group button. 2. Go to the Security Group Creation page.
  3. On the Security Group creation page, enter the required information needed to create the service.
  4. Check the input information and click the Done button.
    • After creation is complete, verify the created resources on the Security Group List page.

2. ## Create Bastion host

Explains the process of configuring a Bastion Host where the Database access client must be installed.

2-1. ### Create Server Keypair

For detailed creation instructions, refer to the Compute > Virtual Server > How-to guides > Keypair guide.
  1. All Services > Compute > Virtual Server Click the menu. 1. Navigate to the Service Home page of the Virtual Server.
  2. On the Service Home page, click the Keypair menu. 2. Go to the Keypair List page.
  3. Create Keypair button, click it. 3. Go to the Keypair creation page.
  4. On the Keypair Creation page, enter the required information needed to create the service.
  5. Verify the creation information and click the Complete button.
    • The key can be downloaded only for the first time, and reissuance is not provided.
    • Please store the downloaded key in a secure location.

2-2. ### Create Bastion host

For detailed creation instructions, refer to the Compute > Virtual Server > How-to guides guide.
  1. Click the All Services > Compute > Virtual Server menu. 1. Navigate to the Service Home page of the Virtual Server.
  2. On the Service Home page, click the Create Virtual Server button. 2. Go to the Create Virtual Server page.
  3. On the Virtual Server Creation page, enter the required essential information needed to create the service.
  4. Summary Check the detailed information and estimated billing amount generated in the panel, and click the Complete button.
    • Once creation is complete, check the created resources on the Virtual Server List page.

2-3. ### Check Bastion host login ID and PW

  1. All Services > Compute > Virtual Server Click the menu. 1. Navigate to the Service Home page of the Virtual Server.
  2. On the Service Home page, click the Virtual Server menu. 2. Go to the Virtual Server List page.
  3. Virtual Serve List page, click the resource you created in 2-2. Bastion host 생성하기. 3. Go to the detailed information page for the resource.
  4. Click the RDP password view button in the Keypair name field on the detail information page. 4. RDP password lookup A popup window opens.
  5. RDP password lookup in the popup window, attach the keypair file downloaded from 2-1. 서버 Keypair 생성하기.
  6. After attaching, click the Password verification button. 6. The ID and password required to access the resource are displayed.

3. ## Create Database

Describes the process of creating a Database service.

3-1. ### PostgreSQL(DBaaS) Create Service

For detailed creation instructions, refer to the Database > PostgreSQL(DBaaS) > How-to guides guide.
  1. All Services > Database > PostgreSQL(DBaaS) Click the menu. 1. Navigate to the Service Home page of PostgreSQL (DBaaS).
  2. On the Service Home page, click the PostgreSQL(DBaaS) Create button. 2. PostgreSQL(DBaaS) Creation Navigate to the page.
  3. PostgreSQL(DBaaS) Creation Enter the required information for service creation on the page.
    • Select the pre‑created VPC and Subnet and connect them.
    • Enter database-related creation information on the required information input screen.
    • Add the Bastion host IP in the IP access control item.
    • The database port defaults to 2866, but users can also specify a different one.
  4. Summary Check the detailed information and estimated billing amount generated in the panel, and click the Complete button.
    • When creation is complete, check the created resource on the PostgreSQL(DBaaS) list page.

4. ## Configure Rules

Describes the process of setting rules for a user to connect to the Bastion host and rules for connecting to the Database from the Bastion host.

4-1. ### Security Group Add security rule

For detailed creation instructions, see the Networking > Security Group > How-to guides guide.
  1. Click the All Services > Networking > Security Group menu. 1. Go to the Service Home page of the Security Group.
  2. On the Service Home page, click the Security Group menu. 2. Navigate to the Security Group List page.
  3. 1-5. 3. Security Group CreateSelect the Security Group resource created in 3. Go to the detailed information page for the resource.
  4. On the detail information page, click the Rules tab. 4. Go to the Rules tab.
  5. Click the Add Rule button on the Rule tab. 5. Add Rule Navigate to the popup window.
  6. Add Rule In the popup window, enter the rule below, and click the Confirm button.
    DirectionRemoteTarget addressProtocolPortExplanation
    InboundCIDRUser PC IPTCP3389 (RDP)Bastion access PC → Bastion host
    OutboundCIDRDB IPTCPDatabase Port (manual entry)Bastion host → Database
    Table. Security Group rules that need to be added

4-2. ### Add IGW Firewall rule

For detailed creation instructions, refer to the Networking > Firewall > How-to guides guide.
  1. All Services > Networking > FirewallClick the menu. 1. Navigate to the Firewall’s Service Home page.
  2. On the Service Home page, click the Firewall menu. 2. Go to the Firewall List page.
  3. On the Firewall List page, select the Internet Gateway resource name created in 1-3. Internet Gateway 생성하기. 3. Go to the detailed information page for the resource.
  4. On the detail information page, click the Rules tab. 4. Go to the Rules tab.
  5. Click the Add Rule button on the Rule tab. 5. Add Rule Navigate to the popup window.
  6. Add Rule In the popup window, enter the rule below, and click the Confirm button.
    Origin addressDestination addressProtocolPortOperationDirectionExplanation
    Bastion connection PC IPBastion host IPTCP3389(RDP)AllowInboundUser PC → Bastion host
    Table. Internet Gateway Firewall rules to be added

5. ## Database Connect

Describes the process of a user connecting to a database through a DB client program.

This guide explains how to connect using pgAdmin. Database client programs and CLI utilities are diverse, so you can install and use the tool that best suits your needs.

5-1. ### Connecting to Bastion host

  1. In the Windows environment of the PC that will connect to the Bastion host, run Remote Desktop Connection, then enter the NAT IP of the Bastion Host and click the Connect button.
  2. When the remote desktop connection succeeds, user credential input window opens. 2. Enter the ID and Password verified in 2-3. Bastion host 접속 ID 및 PW 확인하기 and click the Confirm button.

5-2. ### Install the DB client program (pgAdmin) on the Bastion host

  1. Go to the official pgAdmin page and download the pgAdmin program.
  2. Connect the user’s PC hard drive to upload the file to the Bastion host.
  3. Click the Details button of the Local devices and resources item on the Local Resources tab of the Remote Desktop Connection.
  4. Select the local disk of the location where the file was downloaded on the drive, and click the Confirm button.
  5. Copy the downloaded file, upload it to the Bastion Host, and click the pgAdmin installer to install it.

5-3. ### Connect to the Database using the DB client program (pgAdmin)

  1. Run pgAdmin and click the Add New Server button.
  2. In the Register - Server popup window, enter the Database server information created in 3-1. PostgreSQL(DBaaS) 서비스 생성하기 on the General and Connection tabs, and click the Save button.
    Screen (tab)Required input element iteminput value
    GeneralNameCustom (ex. service name)
    ConnectionHost name/addressDatabase server IP
    ConnectionPortDatabase Port
    ConnectionMaintenance databaseDatabase name
    ConnectionPasswordDatabase password
    Table DB connection client program input fields
  3. Click the name of the database created in pgAdmin to connect.
    • After connecting, you can perform simple queries, etc.
Configure Read Replica
Extension Use