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

Bala Krishna 101 Reputation points
2021-07-30T12:21:59.06+00:00

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 Database
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,855 questions
{count} votes

Accepted answer
  1. Bala Krishna 101 Reputation points
    2021-08-02T08:49:31.887+00:00

    @shiva patpi ,
    I resolved it .issue was my dns . i added correct dns it worked

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. shiva patpi 13,141 Reputation points Microsoft Employee
    2021-08-01T19:21:15.407+00:00

    Hello @Bala Krishna ,
    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.

    0 comments No comments