Azure pods app connect to MSSQL server installed in Azure VM

6/7/2021

I have AZ VM window which installed MSSQL I created cluster in AZ K8S, then create the pod with image - application run with embedded tomcat using MSSQL connect to private IP of the above VM. The container in the pod start with error: can not connect to that private IP of MSSQL I can access to that private IP from my local machine (using VPN), so is there any way/config to make pod can connect to that VM using private IP ? since it's same infrastructure, I dont why it cannot connect (I am newbie with Azure) Thanks alot

-- Cam Lâm Văn
azure
kubernetes
virtual-machine

1 Answer

6/8/2021

For your requirement, I don't know how do you deploy the VM and the AKS cluster. So I give the solutions for the two situations:

  1. AKS cluster with the network type kubelet:
    1. VM in VNet A and AKS in VNet B create a service with the internal load balancer for the pod, and then peer the VNet A and B
    2. VM and AKS in the same VNet create a service with the internal load balancer for the pod
  2. AKS cluster with the network type CNI
    1. VM in VNet A and AKS in VNet B peer the VNet A and B
    2. VM and the AKS in the same VNet you don't do anything, it should work

All of the above solutions need you to check the NSG rules between the VM and the AKS cluster pod. You need to allow the inbound traffic to the VM with the MSSQL port.

-- Charles Xu
Source: StackOverflow