question

BalaKrishna-2429 avatar image
0 Votes"
BalaKrishna-2429 asked vipullag-MSFT commented

Aks pod couldn't able to connect to azure SQL database

I have created a azure aks cluster with this command

az aks create --resource-group $ResourceGroupName --name $AksClusterName --node-count 2 --network-plugin azure --service-cidr 172.18.0.0/16 --dns-service-ip 172.18.0.0 --docker-bridge-address 172.17.0.1/16 --vnet-subnet-id $SUBNET_ID --disable-rbac --node-vm-size Standard_DS3_v2 --network-policy azure

AKS cluster also created successfully. Now i deployed one pod in aks cluster which will communicate with Azure SQL DB.

But pod is couldn't able to communicate with SQL DB . Even though i added AKS subnet IP and Node-ip in SQL DB fire-wall

SQL DB Firewall:-


image

AKS SUBNET :-


image


POD logs:-



at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host test-sqlserver-server-prod-01.database.windows.net, port 1433 has failed. Error: "test-sqlserver-server-prod-01.database.windows.net: Temporary failure in name resolution. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2434)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:659)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2546)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2216)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2067)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1204)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:825)
at org.flywaydb.core.internal.jdbc.DriverDataSource.getConnectionFromDriver(DriverDataSource.java:476)
at org.flywaydb.core.internal.jdbc.DriverDataSource.getConnection(DriverDataSource.java:442)
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:56)
... 35 more


AKS Configuration:-


image

azure-sql-databaseazure-kubernetes-service
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@WinstonHoward-MSFT, is there any help which u can do ?

0 Votes 0 ·

@deherman-MSFT can u please help me on this

0 Votes 0 ·

@BalaKrishna-2429

Just checking in if you got a chance to see previous reply from Shiva.

Please 'Accept as answer' if the provided information is helpful, so that it can help others in the community looking for help on similar topics.

0 Votes 0 ·
BalaKrishna-2429 avatar image
1 Vote"
BalaKrishna-2429 answered vipullag-MSFT commented

@shivapatpi-MSFT ,
I resolved it .issue was my dns . i added correct dns it worked

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@BalaKrishna-2429

Thanks for confirming on the exact issue.

Requesting you to accept the root cause of the issue you mentioned as answer for the benefit of the community.

0 Votes 0 ·
shivapatpi-MSFT avatar image
0 Votes"
shivapatpi-MSFT answered BalaKrishna-2429 converted comment to answer

Hello @BalaKrishna-2429 ,
Thanks for reaching out to Microsoft Q&A.

That is a generic exception , It can be due to multiple reasons mentioned in the below discussion.

https://kb.sos-berlin.com/pages/viewpage.action?pageId=17499564
https://stackoverflow.com/questions/57830490/access-sql-server-database-from-kubernetes-pod

Can you kindly go through above articles ?

Also check if you are able to reach the sql server from the pod :
Login to one of the pod:
nslookup test-sqlserver-server-prod-01.database.windows.net
(if nslookup is not found on the pod install it using the below commands)
apt update
apt install dnsutils

Also try to test it out whether server is reachable using telnet
telnet test-sqlserver-server-prod-01.database.windows.net (Install telnet on the pod using : apt install telnet)

Basically just make sure the "Firewall rule" & "VnetRules" are applied
https://stackoverflow.com/questions/62828549/kubernetes-connect-to-azure-sql

Let us know if those troubleshooting steps helps out in the resolution.






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.