i'm trying to test locally some microservices .NET Core with Minikube. I've 2 microservices that comunicate with each other and with a container with mssql by clusterIP. It works all fine, but i can't connect directly to mssql from SQL Management Studio.
Here the deployment of mssql:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mssql-deployment
spec:
replicas: 1
selector:
matchLabels:
app: mssql
template:
metadata:
labels:
app: mssql
spec:
containers:
- name: mssql
image: mcr.microsoft.com/mssql/server:2017-latest
ports:
- containerPort: 1433
env:
- name: MSSQL_PID
value: "Express"
- name: ACCEPT_EULA
value: "Y"
- name: SA_PASSWORD
valueFrom:
secretKeyRef:
name: mssql
key: SA_PASSWORD
volumeMounts:
- mountPath: /var/opt/mssql/data
name: mssqldb
volumes:
- name: mssqldb
persistentVolumeClaim:
claimName: mssql-claim
---
apiVersion: v1
kind: Service
metadata:
name: mssql-clusterip-service
spec:
type: ClusterIP
selector:
app: mssql
ports:
- name: mssql
protocol: TCP
port: 1433
targetPort: 1433
---
apiVersion: v1
kind: Service
metadata:
name: mssql-loadbalancer
spec:
type: LoadBalancer
selector:
app: mssql
ports:
- protocol: TCP
port: 1433
targetPort: 1433
I've tried also with NodePort but i can't access it by "localhost, 1433" Any idea of how can i access it externally?
Thanks
There is a different way to access your app from external world. If you use the LoadBalancer
type service then you can do the following steps to access your app from external(for only minikube):
minikube tunnel
kubectl get svc
The output looks like:
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 20m
mssql-loadbalancer LoadBalancer 10.102.149.78 10.102.149.78 1433:30373/TCP 16s
http://REPLACE_WITH_EXTERNAL_IP:1443
You can also use a port-forwarding mechanism to access your app like:
kubectl port-forward service/<your service> 1443:1443