Kubernetes服务不公开外部端口 [英] Kubernetes service doesn't expose external port
问题描述
我正在尝试在Kubernetes上本地托管我的第一个dotnet核心应用程序.
I am trying to host my first dotnet core application locally on Kubernetes.
一切正常,但是当我尝试使用z_service.yml文件创建服务时,它不会公开端口8099以便在浏览器中进行外部访问.
$> kubectl apply -f .\z_service.yml
service/amazing-app-service created
但是,如果我运行$> kubectl port-forward amazing-app 8099:80
命令,它将起作用,并且我可以使用 http://localhost来访问浏览器中的Web应用程序:8099/
However if I run $> kubectl port-forward amazing-app 8099:80
command then it works and I can access the web application in browser with http://localhost:8099/
这是服务仪表板的外观
和服务状态
我在这里缺少任何配置吗?
Am I missing any configuration here?
推荐答案
如我所见,它是您的服务amazing-app-service
的NodePort
.当您要将服务公开给Internet时.您应该对服务使用LoadBalancer
类型.就像:
As I see it's NodePort
for your service amazing-app-service
. When you want to expose the service to the Internet. You should use the LoadBalancer
type for the service. Just like:
type: LoadBalancer
这篇关于Kubernetes服务不公开外部端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!