Can't connect Kubernetes pod to RDS Database Can't connect Kubernetes pod to RDS Database kubernetes kubernetes

Can't connect Kubernetes pod to RDS Database


You forgot to mention how did you provision your kubernetes cluster.

  1. Either you use EKS service. In that case, the pod IP address is really a secondary IP address of your EC2 instance (worker node). At least if you use default AWS CNI plugin All that should be needed in that case is really to allow EC2 intance ID in the security group attached to RDS.
  2. You setup your cluster by yourself using kubeadm or something like that and you're using some CNI plugin like calico, flannel or weave. This creates the problem because POD IP addresses are not routed in your VPC. They are completely different from EC2 instance address. What you need to do in this case is setup address translation rule that you will translate source address of pod to IP address of EC2 instance. Follow this guide in that case: https://kubernetes.io/docs/tasks/administer-cluster/ip-masq-agent/