原文链接:https://blog.csdn.net/wxb880114/article/details/86535887
————————————————
问题如图:
原因分析、解决方案
service type 目前有两种,如果使用 gce 的 kubernetes,可以直接使用LoadBalancer类型,gce 会自动帮忙生成一个对外的 ip,并帮你做负载均衡
如果不是在 gce 平台,可以选择使用NodePort的类型,这样会在 node 里面添加一个对外的端口号,可以通过 nodeIP:nodePORT 来访问。可以自己搭建nginx 或者使用云服务商的负载均衡器来做处理。
The yaml you specified for the Service has type: LoadBalancer. That will only work with a cloud provider - so not on your bare metal Ubuntu installation.
Modify the Service definition and specify a different type, for example clusterIP
Try this one if you are using LoadBalancer on an on-premise / bare-metal kubernetes cluster.
https://github.com/google/metallb
From the project description:
Kubernetes does not offer an implementation of network load-balancers (Services of type LoadBalancer) for bare metal clusters. … If you’re not running on a supported IaaS platform (GCP, AWS, Azure…), LoadBalancers will remain in the “pending” state indefinitely when created.
kubernetes-service-external-ip-pengding
It looks like you are using a custom Kubernetes Cluster (using minikube, kubeadm or the like). In this case, there is no LoadBalancer integrated (unlike AWS or Google Cloud). With this default setup, you can only use NodePort (more info here: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) or an Ingress Controller. With the Ingress Controller you can setup a domain name which maps to your pod (more information here: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-controllers)