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
Newsletter
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

  • Treating Web Scrapers Like Production Services
  • Spring Boot's Hidden Secret for Configuration: EnvironmentPostProcessor
  • Best of Three Worlds: AI Agents Writing In Rust and Java Beat the C Library
  • Controller and Data Access: Understanding Two-Layer Architecture Through Abstraction and Encapsulation

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Jan. 22, 19 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
25.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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