Troubleshoot MySQL connectivity from AKS pods

We were stuck in an issue to bring up a Java application dependent on MySQL DB. The application was running on AKS Pod and trying to connect to Azure Database for MySQL. This was a tricky set up as everything was within the virtual Network and public access denied. 

The team thought its connectivity issue, but to isolate that we did 2 quick tests.

  • Spin up a Busybox Pod to do nslookup.
    As we were using Private endpoints to connect to DB, it was important to check if name resolution is working.

kubectl run busybox --image=busybox:1.28 --rm -it -- nslookup <MySQL-SererName>.mysql.database.azure.com

  • Bring up MySQL client Pod to isolate authentication/authorization issues. Send test queries to MySQL by running a temporary container with the mysql:5.7 image and running the MySQL client binary.

Simple query to check the status.

kubectl run mysql-client --image=mysql:5.7 -i --rm --restart=Never --\

mysql -h <MySQL-SererName>.mysql.database.azure.com -u <Username>@<MySQL-SererName> -p<password> <<EOF

PS: It is not recommended to pass credentials in the command. Will write a follow up blog using K8s secrets

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s