停止仅为了查看代码是否能运行而部署到 ECS
Stop Deploying to ECS Just to See If Your Code Works

原始链接: https://metalbear.com/blog/stop-deploying-to-ecs/

mirrord for ECS 可让代码在本地、CI 或智能体沙箱中运行,仿佛它是一个实时预发任务,共享该任务的网络、环境变量、IAM 角色以及对数据库/API 的访问。只有携带会话头的请求才会路由到开发者的版本,因此多人和智能体可以在共享的预发环境中并发测试而无需部署。由于 ECS 缺少 Kubernetes 风格的钩子,设置需要在每个任务定义中一次性添加一个小容器;随后它会在不更改应用镜像的情况下把 mirrord 加载到应用容器中。你的机器和任务各自向 sessions-manager 发起出站 HTTPS 连接,它将两者配对并中继流量,而无需开放入站端口。sessions-manager 可以运行在你的 Kubernetes 集群或 MetalBear Cloud 中,双方都有认证。设置完成后,使用 `mirrord up` 在本地启动服务,发送带会话头的请求,并在出站调用使用任务上下文的同时快速迭代。

Hacker News 新帖 | 过去 | 评论 | 提问 | 展示 | 工作 | 提交 登录 别再部署到 ECS 只为检查代码是否正常 (metalbear.com) 22 分,作者 Liriel,29 分钟前 | 隐藏 | 过去 | 收藏 | 1 条评论 帮助 eyalbukchin 20 分钟前 [–] 大家好,HN,我是 MetalBear 的 Eyal,感谢 Liriel 发帖。确实,使用新的 mirrord for ECS,你在 staging 环境的任务定义中只需一次添加 setup 容器,此后你的本地代码就可以像实时任务一样运行,拥有其网络、环境和 IAM 角色。只有带你的会话头的请求会到达它,staging 上的其他人仍会访问已部署的任务。底线是针对 ECS 的开发周期快得多,显然在代理时代更加重要。 欢迎提问! 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

On ECS, the usual way to find out whether a change works is to deploy it. You build the image, push it, register a new task definition revision, wait for the rollout and look at what happened, then do it all again if it’s wrong. A loop like that might have been tenable for humans, but a coding agent writes a change in seconds, then waits for a full rollout to learn whether it worked, and it rarely gets there on the first try. Most of the speed you got from the agent ends up spent on waiting for rollouts.

Today we’re launching mirrord for ECS. Your code can now run on your laptop, in your CI runner or in your coding agent’s sandbox as if it were a live task in your staging environment, with the task’s network, environment variables and IAM task role. It reaches the same databases, queues, and internal and external APIs as the deployed service. Only the requests that carry your session header come to it, so you, your teammates and your agents can each run your own version of the service at the same time, on the staging environment you already share. You find out whether a change works by simply running it, without deploying anything or spinning up an environment of your own.

Why this didn’t exist on ECS

Nothing else does this on ECS, and there’s a reason for that. Every tool in this category, Telepresence, Signadot and mirrord included, was built on Kubernetes, and leans on it for two main things:

  • Kubernetes lets a tool put its own component next to your service
  • The Kubernetes API gives a developer’s laptop a way to reach that component, controlled by RBAC

ECS has none of it. You can’t add a container to a running task, and there’s no hook that adds one when a task starts. AWS gives you ways to open a shell or forward a port into a task, but nothing that sends the task’s traffic out to your machine, and no shared API that a laptop and a task can both reach and authenticate against. To make mirrord work on ECS, we had to build our own way into the task, and our own way to connect your machine to it and authenticate both sides.

What we built

You add a small setup container to each service’s task definition and deploy it once. It stays in place from then on, so you don’t redeploy to test changes, only to update mirrord itself. When the task starts, the setup container loads mirrord into your app container, where it runs with the app’s network and environment. Your image stays the same.

To connect the two sides, your machine and the task each make an outbound HTTPS connection to a component we call the sessions-manager, which pairs them and relays traffic between them. Neither your machine nor the task has to accept an inbound connection for this, so you don’t open any new ports.

Architecture diagram: a client calls a public load balancer, which routes to an ECS task on Fargate inside an AWS VPC. mirrord runs inside the task's app container, next to the unchanged orders app (v1), which talks to an RDS Postgres database with no public endpoint. The task and the developer's machine or agent sandbox, running orders app v2, each connect out over HTTPS to the sessions-manager in MetalBear Cloud.

mirrord for ECS with the sessions-manager in MetalBear Cloud. mirrord runs inside your app container, and both the task and your machine connect out to the sessions-manager, so your local code reaches the private database through the task.

You choose where the sessions-manager runs: in a Kubernetes cluster of your own, or hosted in MetalBear Cloud. Either way, session traffic passes through it over HTTPS, and both your tasks and your developers have to authenticate to it. The security details are in the docs.

What it looks like after setup

From there, you or your agent start the service locally with mirrord up, then send requests with your session header to the service’s usual staging address:

mirrord login
mirrord up --key $USER

# from another terminal, or from your agent
curl -H "baggage: mirrord-session=$USER" https://orders.staging.example.com/orders

You pick the session key with --key. Requests to staging that carry it go to your machine, and everyone else’s requests still go to the deployed task. Your code’s outgoing calls leave from inside the task, so they reach the private databases and internal APIs that only the task can reach, and your local process runs with the task’s environment and IAM task role. When something’s wrong, you just change the code and run it again, with nothing to build or roll out in between.

Request routing diagram: two requests go through the load balancer to the ECS task. mirrord in the app container checks each one. The request with the baggage header mirrord-session set to your key goes through MetalBear Cloud to the orders app v2 on your machine or agent sandbox. The request without the header is served by the deployed orders app v1.

mirrord checks each request’s session header. Requests with your key go to the code on your machine or in your agent’s sandbox; every other request is served by the deployed task as usual.

Try it

Start at metalbear.com/mirrord/ecs. The ECS sample app uses Terraform to deploy a small service next to a private RDS database, then walks you through running that service locally against the database.

If you’re on another platform, Lambda, Cloud Run, Vercel and Cloudflare are on the waitlist, and you can tell us there which one you need.

What is mirrord?

mirrord is a Kubernetes development platform that lets developers and AI coding agents test code in a production-like environment before deploying it. Your service runs wherever you're working, locally, in CI, or in an agent's sandbox, while mirrord proxies its traffic, environment variables, and files to and from a shared staging cluster, so it behaves as if it were deployed without actually being deployed.

Engineering teams at companies like monday.com, National Australia Bank, and SurveyMonkey use mirrord to iterate and ship faster, while spending less on dev environment infrastructure.

联系我们 contact @ memedata.com