简体   繁体   English

Kubernetes Autoscaling容器

[英]Kubernetes Autoscaling Containers

is it possible to autoscale docker containers, which contain application servers (like wildfly/tomcat/jetty/) within kubernetes ? 是否可以自动缩放docker容器,其中包含kubernetes中的应用程序服务器(如wildfly / tomcat / jetty /)? For example at cpu & ram use or based on http requests ? 例如在cpu&ram使用或基于http请求? If there is a build in feature for that i can't find it, or is it possible to write something like a configuration script for this ? 如果有一个内置功能,我无法找到它,或者是否可以为此编写类似配置脚本的内容? If so where does the magic happen ? 如果是这样,魔法在哪里发生?

目前尚不支持对容器进行自动扩展,这也不是Kubernetes近期1.0路线图的一部分(这意味着核心团队不会很快添加它,但外部贡献肯定是受欢迎的)。

You can use horizontal pod auto-scaling in kubernetes 1.3 onwards. 您可以在kubernetes 1.3之后使用水平pod自动缩放。 kubernetes blog provides detailed information on the functionality. kubernetes博客提供有关功能的详细信息。

http://blog.kubernetes.io/2016/07/autoscaling-in-kubernetes.html http://blog.kubernetes.io/2016/07/autoscaling-in-kubernetes.html

but the above article mainly focus on GKE. 但上面的文章主要关注GKE。 so the below would be more informative. 所以下面会提供更多信息。

https://kubernetes.io/docs/user-guide/horizontal-pod-autoscaling/ https://kubernetes.io/docs/user-guide/horizo​​ntal-pod-autoscaling/

how to use kubectl for pod autoscaling is described here. 这里描述了如何使用kubectl进行pod自动缩放。

 kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]

Examples 例子

# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:
  kubectl autoscale deployment foo --min=2 --max=10

  # Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:
  kubectl autoscale rc foo --max=5 --cpu-percent=80

Since Kubernetes 1.2 autoscaling is part of the stable API. 由于Kubernetes 1.2自动缩放是稳定API的一部分。 It's done based on CPU usage or based on metrics provided from the container itself. 它基于CPU使用情况或基于容器本身提供的指标来完成。

It can be used for deployments or replication controllers like this: 它可以用于部署或复制控制器,如下所示:

# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:
kubectl autoscale deployment foo --min=2 --max=10

# Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:
kubectl autoscale rc foo --max=5 --cpu-percent=80

Further details can be found in the official documentation within the Horizontal scaling description, in the kubectl autoscale documentation and within the official blog . 更多详细信息可以在水平扩展描述, kubectl自动缩放文档和官方博客中的官方文档中找到。

You can autoscale your deployment by using Horizontal Pod Autoscaler. 您可以使用Horizo​​ntal Pod Autoscaler自动调整部署。

 kubectl autoscale deployment task2deploy1 –cpu-percent=80 –min=2 –max=6

The command will ensure the deployment has minimum of 2 and maximum of 6 pods with target CPU utilization set to 80%. 该命令将确保部署最少2个,最多6个pod,目标CPU利用率设置为80%。 You can list the autoscalers using: 您可以使用以下命令列出自动跟踪器:

 kubectl get hpa

NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS 名称参考目标MINIPODS MAXPODS REPLICAS
task2deploy1 Deployment/task2deploy1 /80% 2 6 0 task2deploy1部署/ task2deploy1 / 80%2 6 0

 kubectl describe  hpa 

Name: task2deploy1 名称:task2deploy1

lots of information would be printed on the screen regarding the autoscaler. 有关自动缩放器的信息将在屏幕上打印出大量信息。

Keep checking for the changes in the number of pods using : 使用以下方法继续检查pod数量的变化:

kubectl describe deployment task2deploy1 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JDK 1.6和Servlet容器 - JDK 1.6 and servlet containers 如何使用 Jenkins 将应用程序部署到 EC2 实例(具有自动缩放功能)? - How to deploy an application to EC2 instances(with Autoscaling) using Jenkins? EJB容器的向后兼容性如何? - How backwards compatible are EJB containers? JBOSS / Wildfly集群和Kubernetes- - JBOSS/Wildfly clustering and Kubernetes - 重新部署时不要在WildFly(jBoss)中停止Infinispan缓存容器 - Don's stop Infinispan cache containers in WildFly (jBoss) on redeploy 当客户端和实际应用程序位于不同容器中时配置事务管理器? - Configurating transaction manager when client and actual application are in different containers? 如何使docker容器与非dockerized应用程序通信? - How to make docker containers talk to a non-dockerized application? Docker:运行多个应用程序VS运行多个容器 - Docker: Running multiple applications VS running multiple containers 我应该使用 AWS Elastic Beanstalk 还是 Amazon EC2 Container Service (ECS) 来扩展 Docker 容器? - Should I use AWS Elastic Beanstalk or the Amazon EC2 Container Service (ECS) to scale Docker containers? 是否可以通过docker swarm或kubernetes停止和​​启动特定服务? - Is there ability to stop and start the specific service via docker swarm or kubernetes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM