Minikube Pod Connect to External Database

4/9/2020

I have created a sample application which needs be run inside a kubernetes cluster. For now I am trying to replicate the same environment in my local machine by using Minikube.

Here I have a .Net Core WebAPI service which need to be connect to a MSSQL database. The service is running inside the cluster my the database is in my local machine. I have also created a service to access my MSSQL database engine which at outside the cluster but in my local machine. Here is my configuration file.

My local ip address is 192.168.8.100.

apiVersion: v1
kind: Service
metadata:
  name: mssql
spec:
    ports:
        - protocol: TCP
          port: 3050
          targetPort: 1433

apiVersion: v1
kind: Endpoints
metadata:
    name: mssql
subsets:
    - addresses:
        - ip: "192.168.8.100"
      ports:
        - port: 1433

Pod Connection String

Server=mssql\MSSQLSERVER2017,3050;Database=product-db;User Id=sa;Password=pwd@123;MultipleActiveResultSets=true;

But with the above configuration, it doesn't seems working and throw a connection error. Can someone please tell me where I am doing wrong.

Thanks in advance.

-- Daybreaker
docker
kubernetes
minikube
sql-server

0 Answers