【发布时间】:2021-07-28 00:20:16
【问题描述】:
我创建了一个简单的 Pulumi TypeScript 程序示例,它应该将 Spring Boot 应用程序部署到 AWS ECS Fargate 集群中。 Spring Boot 应用在 Cloud Native Buildpacks/Paketo.io 的帮助下进行了容器化/Docker 化,并发布到 GitHub 容器注册表ghcr.io/jonashackt/microservice-api-spring-boot (example project here)。
我已经阅读了一些 Pulumi 教程,并从通常的 pulumi new aws-typescript 开始。我现在有以下index.ts:
import * as awsx from "@pulumi/awsx";
// Create a load balancer to listen for requests and route them to the container.
let loadbalancer = new awsx.lb.ApplicationListener("alb", { port: 8098, protocol: "HTTP" });
// Define Container image published to the GitHub Container Registry
let service = new awsx.ecs.FargateService("microservice-api-spring-boot", {
taskDefinitionArgs: {
containers: {
microservice_api_spring_boot: {
image: "ghcr.io/jonashackt/microservice-api-spring-boot:latest",
memory: 768,
portMappings: [ loadbalancer ],
},
},
},
desiredCount: 2,
});
// Export the URL so we can easily access it.
export const apiUrl = loadbalancer.endpoint.hostname;
选择dev 堆栈后,正常的pulumi up 会运行并为我提供ApplicationLoadBalancer URL。这里还有一个 asciicast 我准备展示一切顺利:
我现在的问题是 Fargate 服务不断停止和启动。我查看了 CloudWatch 日志,我看到 Spring Boot 应用程序正在启动 - 并且在几秒钟后再次停止。我已经检查了 ApplicationLoadBalancer 的 TargetGroup,我看到 Registered Targets 一次又一次地变为 unhealthy。我该如何解决?
【问题讨论】:
-
也请注意 - AWS 正在努力更新 ecs 控制台。旧版本显示启动错误/容器失败的原因(无法提取图像等)。新的控制台代码虽然在此评论时没有这个有用的小细节
标签: amazon-web-services spring-boot docker aws-fargate pulumi