2

I have a dotnet core pod in Kubernetes(minikube) that need to access to local SQL Server(Testing Server). it work in the container but when i put it in to pod. it can't fine sql server on my machine

but i can ping from pod to my SQL Server

here is the error from log

 An error occurred using the connection to database
> 'ArcadiaAuthenServiceDB' on server '192.168.2.68'.
> System.Data.SqlClient.SqlException (0x80131904): A network-related or
> instance-specific error occurred while establishing a connection to
> SQL Server. The server was not found or was not accessible. Verify
> that the instance name is correct and that SQL Server is configured to
> allow remote connections. (provider: TCP Provider, error: 40 - Could
> not open a connection to SQL Server)  

ping

root@authenservice-dpm-57455f59cf-7rqvz:/app# ping 192.168.2.68
PING 192.168.2.68 (192.168.2.68) 56(84) bytes of data.
64 bytes from 192.168.2.68: icmp_seq=1 ttl=127 time=0.449 ms
64 bytes from 192.168.2.68: icmp_seq=2 ttl=127 time=0.361 ms
64 bytes from 192.168.2.68: icmp_seq=3 ttl=127 time=0.323 ms
64 bytes from 192.168.2.68: icmp_seq=4 ttl=127 time=0.342 ms
^C
--- 192.168.2.68 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3064ms
rtt min/avg/max/mdev = 0.323/0.368/0.449/0.053 ms
root@authenservice-dpm-57455f59cf-7rqvz:/app# 

my Connection String in Container

"DefaultConnection": "Server=mssql-s; Database=ArcadiaAuthenServiceDB; MultipleActiveResultSets=true;User Id=pbts;Password=pbts"

I try to Created Service End-point in Kubernetes but no luck.

Thank you.

EDIT Here The Service.yml File

apiVersion: v1  
     kind: Service  
     metadata: 
         name: mssql-s 
         namespace: default  spec: 
         ports: 
         - port: 1433 
     ---  
     apiVersion: v1  
     kind: Endpoints  
     metadata: 
         name: mssql-s 
         namespace: default  subsets: 
        - addresses: 
        - ip: 192.168.2.68 
         ports: 
         - port: 1433 
     –--

EDIT I check that SQL Server is Listen to 1433 as well

PS C:\Windows\system32> netstat -aon | findstr 1433   
TCP   0.0.0.0:1433           0.0.0.0:0              LISTENING       5028   
TCP   [::]:1433              [::]:0                 LISTENING       5028

Is there anything i can do to solve this problem?

5
  • 1
    What do you mean "local"? Running on the same container? If you mean "running on my host machine" it's not local as far as the container is concerned, it's not even accessible. You'd have to configure networking for the container to enable access to external networks Commented Sep 28, 2018 at 10:18
  • So ping works, but you should find that telnet 192.168.2.68 1433 fails (or netcat to that port), showing that there's no SQL Server listening on that interface. If the virtualized network setup isn't the problem (and it might be), verify that SQL Server is enabled for network access on at least this interface (using SQL Server Configuration Manager). Commented Sep 28, 2018 at 10:23
  • 1
    share you service yaml Commented Sep 28, 2018 at 14:27
  • Thank you for all respond Panagiotis Kanavos I have a SQL Server running on my host machine but not in kubernetes. Jeroen Mostert I'm not sure i understand correctly but i already set the SQL Server to be able to connect via ip address @VKR this is service.yaml apiVersion: v1 kind: Service metadata: name: mssql-e namespace: default spec: ports: - port: 1433 --- apiVersion: v1 kind: Endpoints metadata: name: mssql-e namespace: default subsets: - addresses: - ip: 192.168.2.68 ports: - port: 1433 Commented Oct 1, 2018 at 3:18
  • @Jeroen Mostert Is this what you mean TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING 5028 TCP [::]:1433 [::]:0 LISTENING 5028 Commented Oct 3, 2018 at 4:04

1 Answer 1

1

Thank you for all your reply. Today i found solution. it not about k8s but it about Firewall Setting. I add Inbound rule to allow port 1433. And That it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.