Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access mysql running on localhost from minikube

I am running some services in minikube and trying to connect to mysql running on localhost(127.0.0.1) on 3306 port.

I read this and trying to create service and Endpoints. However, when I specify 127.0.0.1 as IP, it throws error as below:

The Endpoints "mysql-service" is invalid: subsets[0].addresses[0].ip: Invalid value: "127.0.0.1": may not be in the loopback range (127.0.0.0/8)

my deployment is like below:

---
apiVersion: v1
kind: Service
metadata:
  name: mysql-service
spec:
  ports:
  - protocol: TCP
    port: 1443
    targetPort: mysql

---
apiVersion: v1
kind: Endpoints
metadata:
  name: mysql-service
subsets:
  - addresses:
    - ip: 127.0.0.1
    ports:
    - name: mysql
      port: 3306

Please assist me to understand how can I connect to mysql db from minikube.

I have also tried replacing 127.0.0.1 with public IP of my computer(Don't know why though) and connection was timed out.

Any help or guide towards right direction is appreciated.

like image 668
Nirav Avatar asked Mar 14 '19 13:03

Nirav


1 Answers

  According to minikube's document, you can use host.minikube.internal to access your localhost if your minikube's version is higher than v1.10. you can use minikube ssh to confirm connectivity.

like image 160
Chaojun Zhong Avatar answered Oct 21 '22 10:10

Chaojun Zhong