大网数据广告活动
服务器运维问答

Add LoadBalancer to existing service

· 52CE 我爱测

Following this guestbook tutorial . Near the end they sort of gloss over how to create a LoadBalancer or assign NodePorts to the service. They reference this doc that describes the different types and what they do, but don't real…

问题原文

原帖链接 · four43 · CC BY-SA 3.0

Following this guestbook tutorial.

Near the end they sort of gloss over how to create a LoadBalancer or assign NodePorts to the service. They reference this doc that describes the different types and what they do, but don't really go into detail about how to apply them to a service. Is there a way to update the running service, creating and attaching a load balancer to the specified ports?

Using Amazon Web Services to host our cluster, it supports load balancer great at creation of a service, but I'm not sure how to modify the service.

EDIT:

Trying this resulted in an error:

$ kubectl expose service frontend --port=80 --type=LoadBalancer
Error from server: service "frontend" already exists

已采纳解答

原帖链接 · Alex Robinson · CC BY-SA 3.0

It's pretty confusing, but apparently kubectl expose can only create a new service, not update an existing one. It says that when running on an existing service, you should pass a --name flag to specify the desired name of the new service to avoid the conflict you were seeing.

To update a service in place, you should be able to use either kubectl patch or kubectl update. It's probably not the optimal approach, but I personally tend to do this sort of thing by running kubectl get svc svc-name -o yaml > svc.yaml, updating svc.yaml as desired (to have type: LoadBalancer in this case), then kubectl update -f svc.yaml.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-10-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。