Option 1 - use a headless service without selectors
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 (See doc).
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
ports:
- port: 80
targetPort: 8080
---
kind: Endpoints
apiVersion: v1
metadata:
name: my-service
subsets:
- addresses:
- ip: 10.0.2.2
ports:
- port: 8080
Option 2 - use ExternalName
service
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
type: ExternalName
externalName: minikube.host
The only caveat is that it needs to be able to resolve minikube.host
. Simply add this line to the etc/hosts
file should do it.
10.0.2.2 minikube.host
ExternalName
doesn't support port mapping at the moment.
Another note: The IP 10.0.2.2
is known to work with Virtual Box only (see SO).
For xhyve
, try replacing that with 192.168.99.1
(see GitHub issue and issue). A demo GitHub.