Kubernetes怪异:无法访问本地主机,但可以使用curl [英] Kubernetes weirdness: cannot visit localhost, but can use curl

查看:155
本文介绍了Kubernetes怪异:无法访问本地主机,但可以使用curl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注本教程:在Mac OS X上https://kubernetes.io/blog/2019/07/23/get-started-with-kubernetes-using-python/

我已经完成了所有步骤

hello-python-6c7b478cf5-hxfvb   1/1     Running   0          114s
hello-python-6c7b478cf5-rczp9   1/1     Running   0          114s
hello-python-6c7b478cf5-snww5   1/1     Running   0          114s
hello-python-6c7b478cf5-wr8gf   1/1     Running   0          114s

我无法在浏览器上访问localhost:6000.我收到错误消息:

The web page at http://localhost:6000/ might be temporarily down or it may have moved permanently to a new web address.

但是我可以卷曲:

app git:(master) ✗  curl localhost:6000
Hello from Python!%

  • 为什么会这样?

  • 如何修复?

解决方案

如果您在minikube上运行此演示应用程序,则minikube不支持LB外部IP.您可以使用以下命令检查待处理状态:kubectl get svc -o wide.

解决方法: LoadBalancer服务也获得了分配的节点端口,因此您可以通过以下方式访问服务: $ minikube service my-loadbalancer-service-name打开浏览器或添加--url标志以将服务URL输出到终端.您应该看到类似以下内容的内容: $ minikube service hello-python-service --url 该命令将提供url输出.

I am following this tutorial: https://kubernetes.io/blog/2019/07/23/get-started-with-kubernetes-using-python/ on mac osx

I have completed all of the steps

hello-python-6c7b478cf5-hxfvb   1/1     Running   0          114s
hello-python-6c7b478cf5-rczp9   1/1     Running   0          114s
hello-python-6c7b478cf5-snww5   1/1     Running   0          114s
hello-python-6c7b478cf5-wr8gf   1/1     Running   0          114s

I cannot visit localhost:6000 on my browser. I get an error:

The web page at http://localhost:6000/ might be temporarily down or it may have moved permanently to a new web address.

But I can curl:

app git:(master) ✗  curl localhost:6000
Hello from Python!%

  • Why is this happening?

  • How to fix it?

解决方案

If you are running this demo application on minikube then minikube doesn't supports LB external IP. You can check pending status with this command : kubectl get svc -o wide.

Resolution : The LoadBalancer service get a node port assigned too so you can access services via: $ minikube service my-loadbalancer-service-name to open browser or add --url flag to output service URL to terminal. You should see something like: $ minikube service hello-python-service --url this command will give url output .

这篇关于Kubernetes怪异:无法访问本地主机,但可以使用curl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆