有没有办法在启动时使用Route53使用Route53的AWS现场实例寄存器?
我们有一些测试,DEV和CI服务器,我们已经设置了使用Route53映射到特定域的长期运行持续的点实例。这效果很好 - 我们可以节省下来,我们可以分配这些产品而不会过多关注成本,但是由于可用性,我们时不时就失去了实例。当他们回来时 - 他们带着不同的IP地址返回,这破坏了路线。
当这些实例返回在线时(通常在一两分钟之内)时,是否有一个好方法可以自动重新映射到新的IP地址?
We have some test, dev and ci servers that we have setup as long running persistent spot instances mapped to specific domains using route53. This works great - we get the savings, we can allocate these without too much concern about cost but every now and then we loose the instance due to availability. When they come back - they come back with different IP addresses which breaks the route.
Is there a good way to have these instances automatically remap to the new IP address when they come back online (usually within a minute or two)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谨慎:我不相信这种方法毕竟是在起作用。虽然我可以按照我的期望确认所有运行,但在分配了这些机器后,新路线无法正确设置。我不确定这是否是因为该脚本运行时没有启动某些服务,或者亚马逊是否特别禁止这种行为。我很想知道别人发现的东西。
-
nb,正确的答案很可能是使用弹性IP地址,据我了解,我可以完全避免使用一个静态IP地址。我没有对此进行成本计算,但是它可能比下面提供的解决方案便宜。
我们最终提出的是一个使用AWS实例元数据和CLI进行Route53调用的脚本重新启动。这对我们的旧Ubuntu 14.04实例不起作用,但似乎在我们的较新的Ubuntu 20.04实例上。
它的工作方式如下:
setUpRoute53.sh
的小脚本,该脚本知道如何对Route53进行单个调用。我们当前在Ubuntu用户中运行此操作 - crontab看起来像这样:
setupRoute53.sh
看起来像这样:Caution: I'm not convinced this approach is working after all. While I can confirm everything runs as I expected it to - the new routes didn't get setup correctly after these machines were assigned new spot instances. I'm not sure if this is because some service is not started by the time this script runs or if Amazon specifically prohibits this behavior. I'd be curious to hear what others have found.
--
N.B. The right answer here might well be using elastic IP addresses which as I understand allow you to have a single static IP address avoiding this issue altogether. I've not done the cost calculation on this but it might well be cheaper than the solution offered below.
What we ended up coming up with is a script that uses the AWS instance metadata and cli to make a route53 call upon reboot. This did NOT work on our old Ubuntu 14.04 instances but appears to on our newer Ubuntu 20.04 instances.
Here's how it works:
setupRoute53.sh
that knows how to make a single call to route53.We're currently running this within the ubuntu user - the crontab looks like this:
And
setupRoute53.sh
looks like this: