2

I'm trying to access to local MySQL database from minikube container. My minikube works on Windows 10 with hyper-v driver. I found a few solutions (creating host-only network from VirtualBox) but nothing for hyper-v. Can somebody assist me how can I connect to localhost mysql server from minikube hyper-v?

Dennis Spade
  • 21
  • 1
  • 2

2 Answers2

2

Minikube v1.10 added a hostname to the cluster DNS that allows pods to connect to the host. Have your pods use this DNS entry to access the host IP. At this time, the DNS hostname is host.minikube.internal

See docs to learn more.

levibostian
  • 123
  • 4
1

First you need to create a Service and then create an Endpoint with the IP of your MySQL.

apiVersion: v1
kind: Service
metadata:
  name: database
spec:
  ports:
  - port: 3306
    targetPort: 3306
    protocol: TCP
---
# Because this service has no selector, the corresponding Endpoints
# object will not be created. You can manually map the service to
# your own specific endpoints:
kind: Endpoints
apiVersion: v1
metadata:
  name: database
subsets:
  - addresses:
      - ip: "23.99.34.75"
    ports:
      - port: 3306

Also you can check this question Connect to local database from inside minikube cluster.

Crou
  • 714
  • 3
  • 9