9

I am trying to access a simple minikube cluster from the browser, but I keep getting the following: ❗ Because you are using a Docker driver on windows, the terminal needs to be open to run it.

I've created an external service for the cluster with the port number of 30384, and I'm running minikube in a docker container.

I'm follwing "Hello Minikube" example to create my deployment.

Step1: I created the deployment:

kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4

Step2: I created the external service: kubectl expose deployment hello-node --type=LoadBalancer --port=8080

Step3: I ran the service, and that;s where I stuffed up "minikube service hello-node

The full return message:

❗ Executing "docker container inspect minikube --format={{.State.Status}}" took an unusually long time: 2.3796077s Restarting the docker service may improve performance. Starting tunnel for service hello-node. Opening service default/hello-node in default browser... ❗ Because you are using a Docker driver on windows, the terminal needs to be open to run it.

I tried to run the service to make it accessible from the browser, however, I wasn't able to.

Mo Shameri
  • 107
  • 1
  • 5

4 Answers4

15

You can get this working by using kubectl's port forwarding capability. For example, if you are running hello-node service:

kubectl port-forward svc/hello-node 27017:27017

This would expose the service on localhost:27017

You can also mention your pod instead of the service with the same command, you just need to specify your pods/pod-name, you can verify your pod name by kubectl get pods

Aladin
  • 586
  • 3
  • 15
3

I got the same issue resolved it by changing minikube base driver to hyperv from docker.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Your pc will restart after that you can say

minikube config set driver hyperv

Then minikube start will start you with that driver.

This worked for me.

Aniki
  • 336
  • 4
  • 11
  • It wouldn't be his case since he is working with a docker image, how can you get a containerized image in hyper-v? – Aladin Apr 05 '22 at 09:23
  • He can still work with docker image since kubectl is always available no matter the driver. Driver is there only to allow virtualization with the host OS. I also worked with docker image and it worked for me. – Aniki Apr 05 '22 at 09:53
  • Thanks! I also had to append `--url` to the `minikube service` command to get it to output anything. – serg06 Apr 10 '22 at 21:51
2

You can find the alternative in the minikube tutorial, this one works for me on windos:

kubectl port-forward service/hello-minikube 7080:8080

http://localhost:7080/ response:

CLIENT VALUES:
client_address=127.0.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://localhost:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding=gzip, deflate, br
accept-language=es-US,es-419;q=0.9,es;q=0.8,en;q=0.7
connection=keep-alive
host=localhost:7080
sec-ch-ua=" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"
sec-ch-ua-mobile=?0
sec-ch-ua-platform="Windows"
sec-fetch-dest=document
sec-fetch-mode=navigate
sec-fetch-site=cross-site
sec-fetch-user=?1
upgrade-insecure-requests=1
user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
BODY:
-no body in request-
2

try to use:

minikube service --all

it shows and opens the service in browser instance without issue.

Shahid Roofi Khan
  • 957
  • 1
  • 8
  • 19