如何使用gcloud CLI在GCP中的HTTP负载平衡器的后端服务中添加/更新后端的端口 [英] How to add/update the port of a backend in a Backend Service of an HTTP Load Balancer in GCP using gcloud CLI

查看:240
本文介绍了如何使用gcloud CLI在GCP中的HTTP负载平衡器的后端服务中添加/更新后端的端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下命令创建Backen服务:

I can create a Backen Service using the following commands:

# health check
gcloud compute http-health-checks create "$HEALTH_CHECK_NAME"                                       

# backend service
gcloud compute backend-services create "$BACKEND_SERVICE_NAME" --http-health-check "$HEALTH_CHECK_NAME" --port-name "http" --timeout "30"
gcloud compute backend-services add-backend "$BACKEND_SERVICE_NAME" --instance-group "$GROUP_NAME" --balancing-mode "UTILIZATION" --capacity-scaler "1" --max-utilization "1"

但是我还必须添加后端将获取请求的端口。在GCP控制台中,此配置如下所示:

But I have to add also the port the backend will get the requests. In the GCP Console, this configuration looks like this:

如何使用 gcloud CLI设置该端口(或端口号)?

How can I set that port (or port numbers) using the gcloud CLI?

我不能在命令的任何帮助页面找到任何对端口的引用 gcloud compute backend-services update-backend --help gcloud compute backend-services add-backend --help

I can not find any reference to ports in any of the help pages of the commands gcloud compute backend-services update-backend --help and gcloud compute backend-services add-backend --help

推荐答案

实际上在实例组级别提供端口: / p>

Ports are actually supplied at the instance-group level:


# Named Ports for Instance Group
gcloud compute instance-groups managed set-named-ports "$GROUP_NAME" --named-ports "[NAME:PORT,...]" --zone "$ZONE"

在您的情况中,您的后端服务会尝试查找名为 http 的端口。您的端口也是 32656 ,因此命令是:

In your case, your backend-service tries to look for the port with the name http. Also your desired port is 32656, thus the command would be:


gcloud compute instance-groups managed set-named-ports "$GROUP_NAME" --named-ports "http:32656" --zone "$ZONE"

您可以轻松选择名称后端服务使用的端口 - port-name 命令 gcloud compute backend-services create

You can easily choose the name of the port used by the backend-service via argument --port-name of command gcloud compute backend-services create.

查看文档: https://cloud.google.com/sdk/gcloud/reference/compute/backend-services/create

这篇关于如何使用gcloud CLI在GCP中的HTTP负载平衡器的后端服务中添加/更新后端的端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆