I have a deployment have container with node js with typeorm framework run on EKS, I want to connect to RDS Database (PostgreSQL) I already created on same VPC. RDS Database is private access.
I have already configure security group with inbound rules following: Type: Custom TCP Rule Protocol: TCP Port Range: 22 Source: IP Address of machine
Because RDS Database on same VPC .. I've added inbound rules with following: Type: PostgreSQL Protocol: TCP Port Range: 22 Source: IP Address of machine
Then, I set HOST to the IP address source I've already set in inbound rules. I also try to set HOST to connectivity endpoint.
But when I run kubectl logs pod-name, I got error
(node:1) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT <my-ip>:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either
by throwing inside of an async function without a catch block, or by rejecting a promise which was
not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI
flag `--unhandled-rejections=strict` (see
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
I want to connect to my RDS Database with private from my EC2 instance on same VPC, how do I do that. And best practice for connect into RDS Database from EC2 instance on EKS.
UPDATE
After Follow some step base on Kubernetes: Have no access from EKS pod to RDS Postgres
I create service with external name
apiVersion: v1
kind: Service
metadata:
name: postgres-service
spec:
type: ExternalName
externalName: rds-vpc.unique_id.us-east-1.rds.amazonaws.com
I successfully connected to database.. However, whether to connect to a database with the same VPC must use a service?