【发布时间】:2019-05-27 18:02:26
【问题描述】:
我已将我的应用部署在 DigitalOcean 上有限的可用 Kubernetes 集群上。 我有一个 Spring Boot 应用程序,其服务暴露在端口 31744 上,用于使用 nodeport 服务配置进行外部访问。
我使用每个 DO 链接文档的 yaml 配置创建了一个负载均衡器:https://www.digitalocean.com/docs/kubernetes/how-to/add-load-balancer/
但是,我无法连接到我的服务。你能告诉我如何做到这一点,以便我可以从负载均衡器访问我的服务吗?
以下是我的应用服务的“kubectl get svc”输出:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-springboot NodePort 10.245.6.216 <none> 8080:31744/TCP 2d18h
kubernetes ClusterIP 10.245.0.1 <none> 443/TCP 3d20h
sample-load-balancer LoadBalancer 10.245.53.168 58.183.251.550 80:30495/TCP 2m6s
以下是我的loadbalancer.yaml:
apiVersion: v1
kind: Service
metadata:
name: sample-load-balancer
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 31744
name: http
我的 service.yaml:
apiVersion: v1
kind: Service
metadata:
name: my-springboot
labels:
app: my-springboot
tier: backend
spec:
type: NodePort
ports:
# the port that this service should serve on
- port: 8080
selector:
app: my-springboot
tier: backend
谢谢
【问题讨论】:
-
那么当您点击服务命令中显示的外部 IP 时会发生什么?
-
@Sonam,你能分享一下服务配置吗?
-
该外部ip根本没有内容输出。