Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operation timed out when connect to NodePort type deployment locally #14268

Closed
nguyendviet opened this issue Jun 2, 2022 · 11 comments
Closed
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@nguyendviet
Copy link

What Happened?

I start minikube with:

minikube start --driver=docker

I have a simple Node.js app:

import express from "express";
import os from "os";

const app = express();
const PORT = 3000;

app.get("/", (req, res) => {
    const helloMessage = `Hello from the ${os.hostname()}`;
    console.log(helloMessage);
    res.send(helloMessage);
});

app.listen(PORT, () => {
    console.log(`Web server is listening on port ${PORT}`);
});

I create a deployment with NodePort type:

kubectl expose deployment k8s-web-hello --type=NodePort --port=3000
kubectl get svc
NAME            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
k8s-web-hello   NodePort    10.96.41.105   <none>        3000:30734/TCP   10m
kubernetes      ClusterIP   10.96.0.1      <none>        443/TCP          9h
minikue ip
192.168.49.2

If I use minikube ssh, I can curl 192.168.49.2:30734 or curl 10.96.41.105:3000 and get the expected output.

However, if I use:

minikube service k8s-web-hello
🏃  Starting tunnel for service k8s-web-hello.
🎉  Opening service default/k8s-web-hello in default browser...
❗  Because you are using a Docker driver on darwin, the terminal needs to be open to run it.

It opens a new tab on my web browser (Chrome) but it cannot load: http://192.168.49.2:30734/.

I have tried suggested solutions in #11193 including:

minikube service k8s-web-hello --url

🏃  Starting tunnel for service k8s-web-hello.
❗  Because you are using a Docker driver on darwin, the terminal needs to be open to run it.

I get the same result:
Screenshot 2022-06-01 at 22 00 55

minikube version
minikube version: v1.25.2
commit: 362d5fdc0a3dbee389b3d3f1034e8023e72bd3a7

kubectl version
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.1", GitCommit:"3ddd0f45aa91e2f30c70734b175631bec5b5825a"

Mac OS
12.4 (21F79)
M1 chip

Google Chrome
Chrome is up to date
Version 102.0.5005.61 (Official Build) (arm64)

Docker Desktop for MacOS
Version
4.8.2 (79419)

Attach the log file

log.txt

Operating System

macOS (Default)

Driver

Docker

@yuzhaopeng
Copy link

at the macOS ,docker's network has isolate , so you can't access minikube's IP directly.

VPN can solve this problem !

reference here https://github.com/yuzhaopeng/minikube-mac-network

@yuzhaopeng
Copy link

docker for mac's netwoking limit reference https://docs.docker.com/desktop/mac/networking/#i-cannot-ping-my-containers

@nguyendviet
Copy link
Author

@yuzhaopeng Thank you for the suggestion. I'll take a look at it.

@zhan9san
Copy link
Contributor

zhan9san commented Jun 3, 2022

You can get detailed information from this doc.

https://minikube.sigs.k8s.io/docs/handbook/accessing/

You are using the wrong host and port.

After you created the tunnel, you can access your app locally via 127.0.0.1:TUNNEL_PORT instead of minikibe_ip:node_port

@nguyendviet
Copy link
Author

Hi @zhan9san , I'm not sure what you meant but even if I used the wrong port, this command should work:

minikube service k8s-web-hello

but it doesn't.

Also, this command should print out the correct URL but it doesn't (as described above):

minikube service k8s-web-hello --url

@yuzhaopeng
Copy link

minikube service --url it does not work on macOS

@winstonztong
Copy link

winstonztong commented Jun 7, 2022

I was following this blog for testing prometheus locally and minikube service prometheus-server-np worked in minikube v1.24.0 on Darwin 12.4 (tested yesterday), but it doesn't after upgrading minikube to v1.25.2. I haven't found a way to downgrade to v1.24.0 using homebrew.

@spowelljr
Copy link
Member

Hi @winstonztong, if you want to install v1.24.0 you can download your binary from our GitHub releases and then follow the install instructions on our getting started page.

https://github.com/kubernetes/minikube/releases/tag/v1.24.0

https://minikube.sigs.k8s.io/docs/start/

@spowelljr spowelljr added the kind/support Categorizes issue or PR as a support question. label Jun 7, 2022
@zhan9san
Copy link
Contributor

zhan9san commented Jun 8, 2022

@nguyendviet

Could you please try the step in this doc, using-minikube-service-with-tunnel?

And it's better to provide the commands in that sample you run and logs.

If the sample in that doc works, could you apply its strategy to your application?

@nguyendviet
Copy link
Author

Thank you @zhan9san , let me try that.

The log was included in the description above. Please let me know if that's not enough.

@klaases
Copy link
Contributor

klaases commented Jul 13, 2022

Hi @nguyendviet – did @zhan9san's comment help resolve this issue?

Also, is this issue still occurring? Are additional details available? If so, please feel free to re-open the issue by commenting with /reopen. This issue will be closed as additional information was unavailable and some time has passed.

Additional information that may be helpful:

  • Whether the issue occurs with the latest minikube release

  • The exact minikube start command line used

  • Attach the full output of minikube logs, run minikube logs --file=logs.txt to create a log file

Thank you for sharing your experience!

@klaases klaases closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

6 participants