AWS EKS 节点访问 RDS

AWS EKS node to access RDS

我让 AWS EKS 节点访问 RDS,我在 RDS 的安全组中将 EKS 节点的 public IP 列入白名单。但这不是可行的解决方案,因为 EKS 节点可能会被替换,并且它的 public IP 会随之改变。

如何让这个EKS节点连接RDS更稳定?

如果您的 eks 集群与 Rds 实例位于同一个 vpc 中,那么您可以将您的 vpc 的私有 IP 地址 (cidr) 范围列入 RDS 安全组的白名单。如果它们在不同的 vpc 中,则将 vpc 与 vpc-peering 和白名单的 eks vpc 在 rds 安全组中的 IP 范围连接。不要使用 public ip,因为它们会通过外部 AWS 网络。相反,请始终尽可能使用专用连接,因为它们更快、更可靠且更安全。如果您不想将完整的 cidr 列入白名单,那么您还可以为您的 eks 集群创建一个 NAT 网关,并为 EKS 集群外部的外部流量创建路由通过该 NAT 网关,然后您可以在 rds 安全组中将 NAT 的 IP 列入白名单

去年我们推出了一项新功能 to assign Security Groups to Kubernetes pods directly to overcome having to assign them at the node level (to avoid ephemerality problems you call out and to create a more secure environment where only the pod that needs to talk to RDS can do so Vs the ENTIRE node). You can follow this tutorial to configure this feature or refer to the official documentation