Kubernetes service doesn't expose external port

戏子无情 提交于 2020-01-25 06:44:09

问题


I am trying to host my first dotnet core application locally on Kubernetes.

Everything is working fine but when I am trying to create service using z_service.yml file it doesn't expose port 8099 for accessing it externally in browser.

$> kubectl apply -f .\z_service.yml
service/amazing-app-service created

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/

this is how services dashboard looks like

and the services status

Am I missing any configuration here?


回答1:


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



回答2:


In Kubernetes, a service is an abstract layer that binds pods via the local network. If you need external access to your application one of the best ways is to use an ingress object.




回答3:


Why do you have 9999 when your container is listening on 80. Make correction to your service.yaml and then try this in your browser http://localhost:30446



来源:https://stackoverflow.com/questions/59474073/kubernetes-service-doesnt-expose-external-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!