Issue with Database Connect from K8s pod

4/5/2021

I have successfully deployed a pod and service for a Spring-Boot-API to AWS-Kubernetes-Cluster (EKS).

The App connects to a MySQL RDS. RDS and EKS are in different VPCs. I configured a Peering connection and also the routes in the VPCs.

The database is public and I can connect from my local environment.

For the cluster, I configured the environment variables in the deployment-YAML and injected them with config-map (secrets for user and pwd)

When the pod starts I get the following error: java.sql.SQLException: Access denied for user 'admin'@'172.31.35.70' (using password: YES)

I guess that this is a network issue, as the username is resolved correctly!

-- Thomas Lucas
amazon-eks
amazon-rds
kubernetes

1 Answer

4/5/2021

Rule number 1 never make your database public. If you look in the logs, hackers are probably brute-forcing it right now.

The fact you are getting an AccessDenied, suggests the networking is correct, but something is wrong with the password you are supplying.

I would create a bastion in the same subnet as the k8s pod and connect to the database from there with the username and password.

-- David Webster
Source: StackOverflow