Kubernetes 负载均衡器未获取公共 IP
我有一个小型的 ec2 支持(不是 eks)的 k8s 集群(版本 1.23.1),在 aws 中运行,有 1 个主节点和 1 个工作节点。该集群有一些服务,其中之一是基于 Flask 构建的简单前端。我可以使用节点端口服务公开公开 Flask 应用程序,没有任何问题。但我似乎无法让我的负载均衡器正常工作。
flask 应用程序部署:
kind: Deployment
metadata:
name: app-ui
labels:
app: ui
spec:
replicas: 1
selector:
matchLabels:
app: ui
template:
metadata:
labels:
app: ui
spec:
containers:
- name: app-ui
image: **image removed**
ports:
- containerPort: 5000
imagePullSecrets:
- name: docker-hub
节点端口(工作):
通过此节点端口,我可以使用 {{worker_public_ip}}:30000 访问应用程序
apiVersion: v1
kind: Service
metadata:
name: app-ui-nodeport
spec:
type: NodePort
selector:
app: ui
ports:
- protocol: TCP
port: 5000
targetPort: 5000
nodePort: 30000
负载均衡器(不工作)
apiVersion: v1
kind: Service
metadata:
name: app-ui-loadbalancer
spec:
type: LoadBalancer
selector:
app: ui
ports:
- protocol: TCP
port: 5000
targetPort: 5000
负载均衡器的描述
Name: app-ui-loadbalancer
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=ui
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.109.158.206
IPs: 10.109.158.206
Port: <unset> 5000/TCP
TargetPort: 5000/TCP
NodePort: <unset> 32343/TCP
Endpoints: 10.244.1.46:5000
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
如果我错了,请纠正我。我认为这会在 aws 中创建一个实际的负载均衡器。然后使用该负载均衡器的公共 IP,我将能够在端口 5000 上访问该应用程序。
I have a small ec2 backed (not eks) k8s cluster (version 1.23.1), running in aws with 1 master and 1 worker node. The cluster has a few services, one of which is a simple front end built on flask. I am able to expose the flask app publicly using a node port service with out any issues. But I cant seem to get my load balancer to work correctly.
flask app deployment:
kind: Deployment
metadata:
name: app-ui
labels:
app: ui
spec:
replicas: 1
selector:
matchLabels:
app: ui
template:
metadata:
labels:
app: ui
spec:
containers:
- name: app-ui
image: **image removed**
ports:
- containerPort: 5000
imagePullSecrets:
- name: docker-hub
Node port (working):
With this node port I can hit the app using {{worker_public_ip}}:30000
apiVersion: v1
kind: Service
metadata:
name: app-ui-nodeport
spec:
type: NodePort
selector:
app: ui
ports:
- protocol: TCP
port: 5000
targetPort: 5000
nodePort: 30000
Load balancer (not working)
apiVersion: v1
kind: Service
metadata:
name: app-ui-loadbalancer
spec:
type: LoadBalancer
selector:
app: ui
ports:
- protocol: TCP
port: 5000
targetPort: 5000
Description of the load balancer
Name: app-ui-loadbalancer
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=ui
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.109.158.206
IPs: 10.109.158.206
Port: <unset> 5000/TCP
TargetPort: 5000/TCP
NodePort: <unset> 32343/TCP
Endpoints: 10.244.1.46:5000
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Please correct me if im wrong. I thought this would create an actual load balancer in aws. Then using the public ip of that load balancer I would be able to hit the app on port 5000.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
kubectl describe service app-ui-loadbalancer
可能会告诉您有关正在发生的情况的更多信息。具体来说,请检查Events
部分。也许您可能需要添加防火墙规则,或者尝试获取 IP 时出错。kubectl describe service app-ui-loadbalancer
might tell you more about what's going on. Specifically, check theEvents
section. Perhaps you might need to add a firewall rule or it's error trying to get an IP.