Kubernetes怪异:无法访问本地主机,但可以使用curl

编程入门 行业动态 更新时间:2024-10-17 12:18:44
本文介绍了Kubernetes怪异:无法访问本地主机,但可以使用curl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在关注本教程:在Mac OS X上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 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: 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 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

本文发布于:2023-11-28 15:17:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642925.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   怪异   无法访问   主机   Kubernetes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!