Home > Enterprise >  How to connect to AWS RDS (mysql) from EKS pods
How to connect to AWS RDS (mysql) from EKS pods

Time:12-18

Let's say I have one pod from us-east-1 region trying to access a MySQL server in us-east-2, right now when I am doing telnet aws-mysql-server 3306 I get time out.

Question: How to connect to AWS RDS (mysql) from EKS pods?

CodePudding user response:

Separate Region means you are using separate VPC's. You can create VPC peering to communicate between RDS and EKS. First take a look at the VPC peering documentation, then follow the below steps.

  1. Navigate to VPC console: https://console.aws.amazon.com/vpc/
  2. Select Peering Connections and click on Create Peering Connection.
  3. Configure the details as - select the EKS VPC as the Requester and the RDS VPC as the Accepter
  4. Click on Create Peering Connection
  5. Select the Peering Connection that you just created. Click on Actions => Accept. Again, in the confirmation dialog box, click on Yes, Accept.

Don't forget to export the VPC Peering Connection ID

Update the EKS cluster VPC's route table

aws ec2 create-route --route-table-id ${EKS_ROUTE_TABLE_ID} --destination-cidr-block xxx.xxx.0.0/24 --vpc-peering-connection-id ${VPC_PEERING_CONNECTION_ID} 

Update the RDS VPC's route table

aws ec2 create-route --route-table-id ${RDS_ROUTE_TABLE_ID} --destination-cidr-block xxx.xxx.0.0/16 --vpc-peering-connection-id ${VPC_PEERING_CONNECTION_ID}

Update the RDS instance's security group

aws ec2 authorize-security-group-ingress --group-id ${RDS_VPC_SECURITY_GROUP_ID} --protocol tcp --port 3306 --cidr xxx.xxx.0.0/16
  • Related