本文介绍了在现实世界中扩大Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有几个关于缩放Docker容器的基本问题: 我有5个不同的应用程序。它们没有相互连接。在装载容器之前,我将在每个虚拟机上运行1个应用程序,并在云中单独进行扩展。 现在使用容器我可以在虚拟机之上获得隔离现在我可以运行一个拥有5个码头容器的主机,每个应用程序在其自己的容器中被隔离。 只要我的主机上有足够的资源,我可以扩展随着我的交通量增长或收缩,我们可以单独下载这些容器。例如我有3个容器运行应用程序1,但只有1个容器运行应用程序2。 在高峰时段,应用程序3获得了大量流量,我需要启动第二个主机只运行应用程序3的容器。 我的第一个问题是如果上述有意义,我说的话,或者我误解了某些东西。我的第二个问题是什么技术目前可用于以自动的方式完成这项工作。我需要一个负载平衡器和一个自动缩放组,可以在上述情况下进行手动干预。 我研究了AWS ECS,并不太确定有没有人可以满足我的需要,如上所述。 有谁知道如何实现这一点,还是有更好的方式来管理和扩展我的5个应用程序,我失踪了? 更新: 通过Twitter我一直指向 Kubernetes ,具体涉及水平荚自动分页器。 也可能对其他人有用。我会更新这个问题,因为我了解更多。解决方案有几个选项,但是没有一个我知道这样做:您将需要两件事情:根据信号自动缩放主机,然后自动调整主机上的容器。 以下是部署和扩展容器的解决方案>在主机上(不一定 auto -scale): Kubernetes 是一个编排工具,计划和(使用可选的自动缩放器)自动调整群集中的pod(容器组)。如果主机发生故障,它确保您的容器运行在某处。 Google容器引擎(GKE)将此作为服务提供,但是我不确定它们具有与AWS相同的功能来自动调整集群中的VM数量。 Mesos :有些类似于Kubernetes,但不是专门用于运行容器。 Docker Swarm : Docker多主机部署解决方案允许您控制许多主机,就像它们是单个Docker主机一样。我不相信它具有任何自动缩放功能,我不相信它会确保荚总是在某个地方运行,它基本上是群集的停靠点。 Docker支持使用 restart = always 选项重新启动失败的容器, Docker 1.11 Docker Swarm是Docker守护程序中的一种模式,并支持在节点故障时重新安排容器:如果节点不再可用,它将重新启动不同节点上的容器。 Docker 1.11+在功能方面正变得像Kubernetes一样。它有一些不错的功能(如默认节点之间的TLS),但仍然缺乏静态IP和存储配置的功能。 这些解决方案都不会自动调整您的主机数量,但它们可以扩展主机上的容器数量。 对于自动扩展主机,解决方案专门针对您的云提供商,因此这些是专门的解决方案。您的关键部分是集成两个: AWS允许在CoreOS上部署Kubernetes;我不认为他们提供这个服务,所以你需要部署自己的CoreOS集群和Kubernetes。 现在我的个人意见(和免责声明) 大约6个月前,我主要在GKE和裸机上使用Kubernetes,以及Swarm,在GKE上运行〜35条服务:坦率地说,GKE与Kubernetes即服务提供了大部分想要的东西,但并不是AWS。扩展主机仍然有点棘手,需要一些工作。 在AWS或裸机上设置自己的Kubernetes或Mesos是非常可行的,但是有相当的学习曲线:这一切都取决于你是否真的强烈地感觉到在AWS上,并愿意花费时间。 Swarm可能是最容易使用的,但更有限然而,内置脚本可以做好核心工作:使用AWS API来扩展主机,并使用Swarm进行部署。如果节点出现故障,则可用性保证将要求您监视并重新启动容器。 除此之外,还有容器托管提供商可能会执行为你工作: Scalingo是我知道但还有其他人。 https://scalingo.com/ OVH Sail Above有这样的服务。 https://www.runabove.com/sailabove.xml I have a few basic questions on scaling Docker containers:I have 5 different apps. They are not connected to each other. Before having containers I would run 1 app per VM and scale them up and down individually in the cloud.Now with containers I get the isolation on top of a VM, so now I can potentially run one host with 5 docker containers where each app is isolated in its own container.As long as I have enough resources on my host I can scale up and down those containers individually as my traffic grows or shrinks. e.g. I have 3 containers running app 1, but only 1 container running app 2.At peak times app 3 gets a lot of traffic and I need to launch a 2nd host which runs only containers for app 3.My first question is if the above makes sense what I say or if I have misunderstood something. My second question is what technology is currently available to get this all done in an automated way. I need a load balancer and an auto scaling group which is capable of the above scenario without me having to do manual interventions.I looked into AWS ECS and am not quite sure if it can satisfy my needs as I outlined it above.Does anyone know how to achieve this, or is there a better way of managing and scaling my 5 apps which I am missing?UPDATE:Via Twitter I have been pointed to Kubernetes and specifically to the docs on the Horizontal Pod Autoscaler.Might be useful for others as well. I will update this question as I learn more. 解决方案 There are several options, but none that I know that does it all: you will need 2 things: autoscaling hosts according to signals, then autoscale containers on the hosts.The following are the solutions to deploy and scale containers on the hosts (not necessarily auto-scale though):Kubernetes is an orchestration tool which allows to schedule and (with the optional autoscaler) to autoscale pods (groups of containers) in the cluster. It makes sure your containers are running somewhere if a host fails.Google Container Engine (GKE) offers this as a service, however i am not sure they have the same functionalities to autoscale the number of VMs in the cluster as AWS does.Mesos: somewhat similar to Kubernetes but not dedicated to running containers.Docker Swarm: the Docker multi-host deployment solution, allows you control many hosts as if they were a single Docker host. I don't believe it has any kind of 'autoscaling' capability, and I don't believe it takes care of making sure pods are always running somewhere: it's basically docker for cluster.[EDIT] Docker supports restarting failing containers with the restart=always option, also, as of Docker 1.11 Docker Swarm is a mode in Docker Daemon, and supports rescheduling containers on node failure: it will restart containers on a different node if a node is no longer available.Docker 1.11+ is becoming a lot like Kubernetes in terms of functionalities. It has some nice features (like TLS between nodes by default), but still lacks things like static IPs and storage provisioningNone of these solutions will autoscale the number of hosts for you, but they can scale the number of containers on the hosts.For autoscaling hosts, solutions are specific to your cloud provider, so these are dedicated solution. The key part for you is to integrate the two:AWS allows deployment of Kubernetes on CoreOS; I don't think they offer this as a service, so you need to deploy your own CoreOS cluster and Kubernetes.Now my personal opinion (and disclaimer)I have mostly used Kubernetes on GKE and bare-metal, as well as Swarm a about 6 months ago, and i run an infra with ~35 services on GKE:Frankly, GKE with Kubernetes as a Service offers most of what you want, but it's not AWS. Scaling hosts is still a bit tricky and will require some work.Setting up your own Kubernetes or Mesos on AWS or bare metal is very feasible, but there is quite a learning curve: it all depends if you really strongly feel about being on AWS and are willing to spend the time.Swarm is probably the easiest to get working with, but more limited, however homebuilt script can well do the job core job: use AWS APIs to scale hosts, and Swarm to deploy. The availability guarantee though would require you monitoring and take care of re-launching containers if a node fails.Other than that, there are also container hosting providers that may do the job for you:Scalingo is one i know of but there are others. https://scalingo.com/OVH Sail Above has this service in alpha. https://www.runabove.com/sailabove.xml 这篇关于在现实世界中扩大Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-24 22:52