SQL Tools on a pod on AKS to manage your Azure SQL databases
Posted by Florent Appointaire on
July 27, 2021
If you want to manage/test connectivity to your private SQL server, that are using private endpoint for example, and without deploying a VM, installing SQL Server Management Studio and so on, you can use AKS to do this.
To start, deploy a pod that we will customize later:
|
kubectl apply -f https://k8s.io/examples/application/shell-demo.yaml |
|
Connect to the pod itself:
|
kubectl exec -it shell-demo -- /bin/bash |
|
Install sqlcmd tool:
|
apt-get update && apt-get install gnupg2 curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | tee /etc/apt/sources.list.d/msprod.list apt-get update && apt-get install mssql-tools unixodbc-dev ls /opt/mssql-tools/bin/sqlcmd* ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd |
|

Connect to your database server, with the following sql command, and your credentials:
|
kubectl exec -it shell-demo -- /bin/bash sqlcmd -S starwind.database.windows.net -U starwind -P 'Demo2021!' select name from sys.databases go |
|

This is very interesting to manage your databases, or to try a connection from a private AKS cluster to a SQL Server that is using a private endpoint connection for example.
Related materials:
Filed under:
Software by Florent Appointaire