<p>I'm trying to setup kubernetes on AWS. For this I created an EKS cluster with 3 nodes (t2.small) according to official AWS tutorial. Then I want to run a pod with some app which communicates with Postgres (RDS in different VPC). </p>

<p>But unfortunately the app doesn't connect to the database.</p>

<p>What I have:</p>

<ol>
<li>EKS cluster with its own VPC (CIDR: 192.168.0.0/16)</li>
<li>RDS (Postgres) with its own VPC (CIDR: 172.30.0.0/16)</li>
<li>Peering connection initiated from the RDS VPC to the EKS VPC</li>
<li>Route table for 3 public subnets of EKS cluster is updated: route with destination 172.30.0.0/16 and target — peer connection from the step #3 is added.</li>
<li>Route table for the RDS is updated: route with destination 192.168.0.0/16 and target — peer connection from the step #3 is added.</li>
<li>The RDS security group is updated, new inbound rule is added: all traffic from 192.168.0.0/16 is allowed</li>
</ol>

<p>After all these steps I execute kubectl command:</p>

<pre><code>kubectl exec -it my-pod-app-6vkgm nslookup rds-vpc.unique_id.us-east-1.rds.amazonaws.com
nslookup: can't resolve '(null)': Name does not resolve

Name:      rds-vpc.unique_id.us-east-1.rds.amazonaws.com
Address 1: 52.0.109.113 ec2-52-0-109-113.compute-1.amazonaws.com
</code></pre>

<p>Then I connect to one of the 3 nodes and execute a command:</p>

<pre><code>getent hosts rds-vpc.unique_id.us-east-1.rds.amazonaws.com
52.0.109.113    ec2-52-0-109-113.compute-1.amazonaws.com rds-vpc.unique_id.us-east-1.rds.amazonaws.com
</code></pre>

<p>What I missed in EKS setup in order to have access from pods to RDS?</p>

<p><strong>UPDATE:</strong></p>

<p>I tried to fix the problem by <code>Service</code>:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: postgres-service
spec:
  type: ExternalName
  externalName: rds-vpc.unique_id.us-east-1.rds.amazonaws.com
</code></pre>

<p>So I created this service in EKS, and then tried to refer to <code>postgres-service</code> as DB URL instead of direct RDS host address.</p>

<p>This fix does not work :(</p>

<p>Have you tried to enable "dns propagation" in the peering connection? It looks like you are not getting the internally routable dns. You can enable it by going into the setting for the peering connection and checking the box for dns propagation. I generally do this will all of the peering connections that I control.</p>
