DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • How to Build and Deploy an AI Agent on Kubernetes With AWS Bedrock, FastAPI and Helm
  • Building a Platform Abstraction for EKS Cluster Using Crossplane
  • Demystifying Kubernetes on AWS: A Comparative Analysis of Deployment Options
  • How to Use Jenkins Effectively With ECS/EKS Cluster

Trending

  • How SaaS Architectures Break at Scale — and the Engineering Decisions That Prevent It
  • Why Your Test Automation Is Always Behind the Code And the Architecture That Fixes It
  • Your AI Agent Tests Are Passing, But Your Agent Is Still Broken
  • Feature Flag Debt: Performance Impact in Enterprise Applications
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Kubernetes on AWS: How to Connect to RDS

Kubernetes on AWS: How to Connect to RDS

If you're looking to access RDS from Amazon EKS, then this is the post for you.

By 
Alexey Zvolinskiy user avatar
Alexey Zvolinskiy
·
Jan. 22, 19 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
25.7K Views

Join the DZone community and get the full member experience.

Join For Free

Hey there! It’s time to write a new blog post about something really hot — Kubernetes. In order to make this article even spicier, I want to talk about Kubernetes in terms of AWS and access to a database. So basically this post is for those of you who want to set up a Kubernetes application on Amazon Cloud and configure access to RDS (Postgres/MySQL) from the application. Let’s get started!

A long time ago, the software development world was taken by storm with the concept of containerization. Since that time, every backend developer should know what is Docker and how to use it. That was only the beginning of something bigger. Today, I can definitely say that containers without proper orchestration and service discovery mechanism are pretty useless. Here is where Kubernetes comes in.

How to Access RDS from EKS

AWS has its own service to run apps in Kubernetes — EKS. It’s definitely not as easy as its GCP alternative, but it’s not so hard to set up a K8s cluster in Amazon Cloud, especially if you do it with the official AWS tutorial. The problem appears when you want to do something more custom, rather than starting a regular K8s cluster. One example is when you want to access a database (RDS in terms of AWS). In order to understand this problem more deeply, I want to describe some technicals.

When we create a K8s cluster in EKS, a new VPC with its own CIDR IP is created. The same is true for RDS. VPCs by definition are closed for communication with the external world. To overcome this we need to use some hook.

AWS has such a mechanism — peering connection. The first step you need to do in order to set up access from the K8s cluster to the database, is to create a peering connection. The connection should be initiated from the RDS VPC to the EKS VPC.

Then routing tables need to be updated for both of VPCs. For the EKS routing table a new route should be created with a destination which corresponds to CIDR IP of RDS VPC, and the peering connection as a target. Similarly, you need to create a new route for the RDS routing table. This step, probably, is the most tricky one.

Next, you have to update the RDS security group. Add a new rule which allows all traffic from EKS CIDR IP.

Finally, go to the peering connection and change its configuration by enabling a DNS propagation.

That’s it. After this long way, your app which runs on AWS EKS should be able to access a database hosted in RDS. I hope that this article will help you to tackle an issue of accessing RDS from Kubernetes on AWS.

This article is based on my Stackoverflow question.

AWS Kubernetes

Published at DZone with permission of Alexey Zvolinskiy. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Build and Deploy an AI Agent on Kubernetes With AWS Bedrock, FastAPI and Helm
  • Building a Platform Abstraction for EKS Cluster Using Crossplane
  • Demystifying Kubernetes on AWS: A Comparative Analysis of Deployment Options
  • How to Use Jenkins Effectively With ECS/EKS Cluster

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook