im Running Kubernetes (minikube) on Windows via Virtualbox. I've got a Services running on my Host-Service i dont want to put inside my Kubernetes Cluster, how can i access that Services from Inside my Pods?
Im new to to Kubernetes i hope this Questions isnt to stupid to ask.
I tried to create a Service + Endpoint but it didnt work:
kind: Endpoints
apiVersion: v1
metadata:
name: vetdb
subsets:
- addresses:
- ip: 192.168.99.100
ports:
- port: 3307
kind: Service
apiVersion: v1
metadata:
name: vetdb
spec:
selector:
app: vetdb
type: ClusterIP
ports:
- port: 3306
targetPort: 3307
i started a ubuntu image inside the same cluster the pod should be running on later and tested the connection:
$ root@my-shell-7766cd89c6-rtxt2:/# curl vetdb:3307 --output test
Host '192.168.99.102' is not allowed to connect to this MariaDB serverroot@my-shell
This is the same Output i get running (except other Host-IP)
curl 192.168.99.100:3307
on my Host PC ==> Itworks.
But i cant access the Host from inside my Microservices where i really need to access the URL.
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
eureka-77f949499-g2l82 1/1 Running 0 2h
my-shell-7766cd89c6-rtxt2 1/1 Running 0 2h
vet-ms-54b89f9c86-29psf 1/1 Running 10 18m
vet-ms-67c774fd9b-2fnjc 0/1 CrashLoopBackOff 7 18m
The Curl Response i posted above was from Pod: my-shell-7766cd89c6-rtxt2
But i need to access vetdb from vet-ms-*
$ kubectl logs -f vet-ms-67c774fd9b-2fnjc
...
Caused by: java.net.UnknownHostException: vetdb
...
Spring URL Settings i tried
spring.profiles.datasource.url: jdbc:mysql://vetdb:3307/vetdb?useSSL=false&allowPublicKeyRetrieval=true
spring.profiles.datasource.url: jdbc:mysql://vetdb:3306/vetdb?useSSL=false&allowPublicKeyRetrieval=true
spring.profiles.datasource.url: jdbc:mysql://vetdb/vetdb?useSSL=false&allowPublicKeyRetrieval=true
Ty guys
Edit:// i allowed every Host to Connect to the DB to remove this error
Host '192.168.99.102' is not allowed to connect to this MariaDB
but i still get the Same Unknown Host Exception inside of my Microservices.