目录

AWS Get Started

AWS 在部署容器时提供了很多选项。但是知道哪种服务能做什么,即使是经验丰富的专业人士也会感到头痛。

了解每个服务的角色

本质上,每个服务都是编排层(管理容器)或宿主层(运行容器)的一部分:

  • ECS、EK 和 Kuberneretes 是编排层的一部分;
  • EC2 和 Fargate 是宿主层的一部分;

EKS vs ECS vs Kuberneretes - 编排层

https://prof.justaftermidnight247.com/wp-content/uploads/2021/03/2-768x512.png

容器编排服务自动化管理容器的手动工作。编排的主要好处是:

  • Simplifying Operations - 自动部署和创建新容器;
  • Adding Resilience - 自动管理故障和容器生命周期;
  • Adding Security - 消除由于用户错误而造成的违规行为,并自动化安全最佳实践;

ECS - Elastic Container Service

AWS 自己的容器服务。它在集群中管理容器,被称为 ECS 集群。

EKS - Elastic Kuberneretes Service

EKS 是一种 AWS 容器服务,它与 ECS 的不同之处在于它用于管理 AWS 基础设施上的 Kubernetes 集群。还可以将现有的 Kubernetes 工作负载迁移到 EKS 上。

Kubernetes

Kubernetes 是开源的容器编排服务,非常流行,但要在 AWS 上部署 Kubernetes,可以说必须使用 EKS 来实现。

ECS vs EKS

ECS pros

  • ECS 是 AWS 自己的容器服务,因此它与 AWS 生态系统,包括 CloudTrail,CloudWatch 和 Amazon ECR(弹性容器注册)进行了更好的集成,以实现对 Docker 映像的无缝管理;
  • ECS 控制面板完全自由,而 EKS 需要充值;

EKS pros

  • 由于 EKS 使用 Kubernetes,所以它更加灵活,这意味着可以比 ECS 更轻松地将工作迁移到另一个平台,使其更适合复杂的多云工作负载;
  • EKS 更适合复杂的应用;
  • EKS 最终提供了比 ECS 更多的控制(对集群的管理和调度);

结论

如果需要一个更简单的应用程序,并且希望合并许多 AWS 服务,ECS 可能是比较好的选择。如果有一个更复杂的项目,特别是如果想要使用多云方法,EKS 是正确的选择——显然,如果想要使用 Kubernetes 时。

Fargate vs EC2 – 宿主层

https://prof.justaftermidnight247.com/wp-content/uploads/2021/03/1-768x512.png

容器部署的宿主层表示容器将实际运行的虚拟机(或承载的虚拟机,因此得名)。

EC2

Deploy and manage your own cluster of EC2 instances for running the containers.

EC2 是部署容器的传统方式。在 EC2 中,通过实际的 VM 进行运行。

Fargate

Run containers directly, without any EC2 instances.

Fargate 带来了一种无服务器的方式,Fargate 不是自己配置服务器,而是根据每个请求自动为容器配置基础设施。

EC2 vs Fargate

EC2 pros

  • EC2 意味着更多的手工工作,但是有更多的控制力和透明度(因为你自己需要配置基础设施);
  • 需要熟悉 EC2;

Fargate pros

  • Fargate 意味着更少的工作,通常成本更低(需要你为消耗的资源付费),对应的控制力和透明度更低;
  • Fargate 是无服务器的,这种方式是以后的常态;

结论

如果有时间和预算,并且需要额外的监督和控制,EC2 是更好的选择。如果想要降低成本和减轻负担,Fargate 是个不错的选择。

Benefits of infrastructure as code

以下摘自 AWS 官网。

  • Visibility: An infrastructure as code template serves as a very clear reference of what resources are on your account, and what their settings are. You don’t have to navigate to the web console to check the parameters.
  • Stability: If you accidentally change the wrong setting or delete the wrong resource in the web console you can break things. Infrastructure as code helps solve this, especially when it is combined with version control, such as Git.
  • Scalability: With infrastructure as code you can write it once and then reuse it many times. This means that one well written template can be used as the basis for multiple services, in multiple regions around the world, making it much easier to horizontally scale.
  • Security: Once again infrastructure as code gives you a unified template for how to deploy your architecture. If you create one well secured architecture you can reuse it multiple times, and know that each deployed version is following the same settings.
  • Transactional: CloudFormation not only creates resources on your AWS account but also waits for them to stabilize while they start. It verifies that provisioning was successful, and if there is a failure it can gracefully roll the infrastructure back to a past known good state.