AWS中两个容器能否在同一IP:PORT上来回交换服务?
创始人
2024-09-28 04:30:12
0

AWS中的Elastic Load Balancer(ELB)可用于将流量分发到一组容器,可确保在同一端口上发生容器之间的无缝交换。可以使用AWS中的ECS(Elastic Container Service)和ALB(Application Load Balancer)来实现这一点。

以下是通过AWS ECS和ALB实现背靠背容器服务同一个IP:PORT的示例代码:

1.创建ECS任务定义:

{
     "family": "my-task",
     "containerDefinitions": [
         {
             "name": "container-1",
             "image": "image-1",
             "portMappings": [
                 {
                     "containerPort": 80,
                     "hostPort": 0
                 }
             ]
         },
         {
             "name": "container-2",
             "image": "image-2",
             "portMappings": [
                 {
                     "containerPort": 80,
                     "hostPort": 0
                 }
             ]
         }
     ]
 }

2.创建ECS服务:

{
     "cluster": "my-cluster",
     "serviceName": "my-service",
     "taskDefinition": "my-task",
     "desiredCount": 2,
     "loadBalancers": [
         {
             "targetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:0123456789012:targetgroup/my-target-group/abcdef0123456789",
             "containerName": "container-1",
             "containerPort": 80
         },
         {
             "targetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:0123456789012:targetgroup/my-target-group/abcdef0123456789",
             "containerName": "container-2",
             "containerPort": 80
         }
     ]
 }

3.创建ALB目标组:

{
     "Name": "my-target-group",
     "Port": 80,
     "Protocol": "HTTP",
     "Targets": [
         {
             "Id": "container-1",
             "Port": 

相关内容

热门资讯

透视透视!werplan透视挂... 透视透视!werplan透视挂(透视)wepoker透视脚本下载,教程妙招(发现有挂)-哔哩哔哩1、...
透视解谜!poker mast... 透视解谜!poker master辅助(透视)德州局hhpoker,教程经验(有挂透明挂)-哔哩哔哩...
透视分享!wepoker透视底... 透视分享!wepoker透视底牌(透视)hhpoker辅助挂是真的吗,教程绝活(真实有挂)-哔哩哔哩...
透视专业!wpk有那种辅助吗(... 透视专业!wpk有那种辅助吗(透视)约局吧如何查看是否有挂,教程技法(有挂技术)-哔哩哔哩约局吧如何...
透视透视!wepokerplu... 透视透视!wepokerplus脚本(透视)wepoker透视脚本苹果版,教程操作(了解有挂)-哔哩...
透视透视!hhpoker可以控... 透视透视!hhpoker可以控制牌吗(透视)hardrock透视,教程要领(有挂透视)-哔哩哔哩1、...
透视必备!wepoker轻量版... 透视必备!wepoker轻量版透视(透视)wepoker黑侠辅助器正版下载,教程指南(有挂细节)-哔...
透视揭幕!pokemmo辅助器... 透视揭幕!pokemmo辅助器(透视)wepoker透视挂底牌,教程诀窍(有挂总结)-哔哩哔哩1、进...
透视专业!悦扑克脚本(透视)德... 透视专业!悦扑克脚本(透视)德州局透视脚本,教程教程书(有挂方式)-哔哩哔哩1、玩家可以在德州局透视...
透视总结!wepoker辅助器... 透视总结!wepoker辅助器软件下载(透视)hhpoker有后台操控吗,教程经验(有挂存在)-哔哩...