2017-08-21 17:44:43 +08:00
<!DOCTYPE HTML>
2017-09-19 22:01:07 +08:00
< html lang = "zh-hans" >
2017-08-21 17:44:43 +08:00
< head >
< meta charset = "UTF-8" >
< meta content = "text/html; charset=utf-8" http-equiv = "Content-Type" >
< title > 2.2.16 Horizontal Pod Autoscaling · Kubernetes Handbook< / title >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" / >
< meta name = "description" content = "" >
< meta name = "generator" content = "GitBook 3.2.2" >
< meta name = "author" content = "Jimmy Song" >
< link rel = "stylesheet" href = "../gitbook/style.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-splitter/splitter.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-page-toc-button/plugin.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-image-captions/image-captions.css" >
2017-10-09 15:28:05 +08:00
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-back-to-top-button/plugin.css" >
2017-08-21 17:44:43 +08:00
2017-10-09 15:28:05 +08:00
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-search-plus/search.css" >
2017-09-19 21:38:03 +08:00
2017-10-09 15:28:05 +08:00
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css" >
2017-08-21 17:44:43 +08:00
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-highlight/website.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-fontsettings/website.css" >
2017-10-09 15:28:05 +08:00
2017-08-21 17:44:43 +08:00
< meta name = "HandheldFriendly" content = "true" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1, user-scalable=no" >
< meta name = "apple-mobile-web-app-capable" content = "yes" >
< meta name = "apple-mobile-web-app-status-bar-style" content = "black" >
< link rel = "apple-touch-icon-precomposed" sizes = "152x152" href = "../gitbook/images/apple-touch-icon-precomposed-152.png" >
< link rel = "shortcut icon" href = "../gitbook/images/favicon.ico" type = "image/x-icon" >
< link rel = "next" href = "label.html" / >
< link rel = "prev" href = "configmap.html" / >
2017-10-09 15:28:05 +08:00
< link rel = "shortcut icon" href = '../favicon.ico' type = "image/x-icon" >
< link rel = "bookmark" href = '../favicon.ico' type = "image/x-icon" >
< style >
@media only screen and (max-width: 640px) {
.book-header .hidden-mobile {
display: none;
}
}
< / style >
< script >
window["gitbook-plugin-github-buttons"] = {"repo":"rootsongjc/kubernetes-handbook","types":["star"],"size":"small"};
< / script >
2017-08-21 17:44:43 +08:00
< / head >
< body >
< div class = "book" >
< div class = "book-summary" >
< div id = "book-search-input" role = "search" >
2017-09-19 22:01:07 +08:00
< input type = "text" placeholder = "输入并搜索" / >
2017-08-21 17:44:43 +08:00
< / div >
< nav role = "navigation" >
< ul class = "summary" >
2017-10-09 15:28:05 +08:00
< li >
< a href = "https://jimmysong.io" target = "_blank" class = "custom-link" > Home< / a >
< / li >
2017-08-21 17:44:43 +08:00
2017-10-09 15:28:05 +08:00
< li class = "divider" > < / li >
2017-08-21 17:44:43 +08:00
< li class = "chapter " data-level = "1.1" data-path = "../" >
< a href = "../" >
2017-10-20 10:51:14 +08:00
序言
2017-08-21 17:44:43 +08:00
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.2" data-path = "../cloud-native/kubernetes-and-cloud-native-app-overview.html" >
< a href = "../cloud-native/kubernetes-and-cloud-native-app-overview.html" >
1. Kubernetes与云原生应用概览
< / a >
< / li >
< li class = "chapter " data-level = "1.3" data-path = "./" >
2017-08-21 17:44:43 +08:00
< a href = "./" >
2. 概念原理
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.1" data-path = "concepts.html" >
2017-08-21 17:44:43 +08:00
< a href = "concepts.html" >
2.1 设计理念
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2" data-path = "objects.html" >
2017-08-21 17:44:43 +08:00
< a href = "objects.html" >
2017-09-03 13:29:38 +08:00
2.2 Objects
2017-08-21 17:44:43 +08:00
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.1" data-path = "pod-overview.html" >
2017-08-21 17:44:43 +08:00
< a href = "pod-overview.html" >
2.2.1 Pod
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.1.1" data-path = "pod.html" >
2017-08-21 17:44:43 +08:00
< a href = "pod.html" >
2.2.1.1 Pod解析
< / a >
2017-08-31 23:28:33 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.1.2" data-path = "init-containers.html" >
2017-08-31 23:28:33 +08:00
< a href = "init-containers.html" >
2.2.1.2 Init容器
< / a >
2017-09-03 15:58:39 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.1.3" data-path = "pod-security-policy.html" >
2017-09-03 15:58:39 +08:00
< a href = "pod-security-policy.html" >
2.2.1.3 Pod安全策略
< / a >
2017-09-17 15:39:26 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.1.4" data-path = "pod-lifecycle.html" >
2017-09-17 15:39:26 +08:00
< a href = "pod-lifecycle.html" >
2.2.1.4 Pod的生命周期
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.2" data-path = "node.html" >
2017-08-21 17:44:43 +08:00
< a href = "node.html" >
2.2.2 Node
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.3" data-path = "namespace.html" >
2017-08-21 17:44:43 +08:00
< a href = "namespace.html" >
2.2.3 Namespace
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.4" data-path = "service.html" >
2017-08-21 17:44:43 +08:00
< a href = "service.html" >
2.2.4 Service
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.5" data-path = "volume.html" >
2017-08-21 17:44:43 +08:00
< a href = "volume.html" >
2.2.5 Volume和Persistent Volume
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.6" data-path = "deployment.html" >
2017-08-21 17:44:43 +08:00
< a href = "deployment.html" >
2.2.6 Deployment
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.7" data-path = "secret.html" >
2017-08-21 17:44:43 +08:00
< a href = "secret.html" >
2.2.7 Secret
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.8" data-path = "statefulset.html" >
2017-08-21 17:44:43 +08:00
< a href = "statefulset.html" >
2.2.8 StatefulSet
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.9" data-path = "daemonset.html" >
2017-08-21 17:44:43 +08:00
< a href = "daemonset.html" >
2.2.9 DaemonSet
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.10" data-path = "serviceaccount.html" >
2017-08-21 17:44:43 +08:00
< a href = "serviceaccount.html" >
2.2.10 ServiceAccount
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.11" data-path = "replicaset.html" >
2017-08-21 17:44:43 +08:00
< a href = "replicaset.html" >
2.2.11 ReplicationController和ReplicaSet
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.12" data-path = "job.html" >
2017-08-21 17:44:43 +08:00
< a href = "job.html" >
2.2.12 Job
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.13" data-path = "cronjob.html" >
2017-08-21 17:44:43 +08:00
< a href = "cronjob.html" >
2.2.13 CronJob
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.14" data-path = "ingress.html" >
2017-08-21 17:44:43 +08:00
< a href = "ingress.html" >
2.2.14 Ingress
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.15" data-path = "configmap.html" >
2017-08-21 17:44:43 +08:00
< a href = "configmap.html" >
2.2.15 ConfigMap
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter active" data-level = "1.3.2.16" data-path = "horizontal-pod-autoscaling.html" >
2017-08-21 17:44:43 +08:00
< a href = "horizontal-pod-autoscaling.html" >
2.2.16 Horizontal Pod Autoscaling
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.17" data-path = "label.html" >
2017-08-21 17:44:43 +08:00
< a href = "label.html" >
2.2.17 Label
< / a >
2017-09-03 15:58:39 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.18" data-path = "garbage-collection.html" >
2017-09-03 15:58:39 +08:00
< a href = "garbage-collection.html" >
2.2.18 垃圾收集
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.3.2.19" data-path = "network-policy.html" >
2017-09-03 15:58:39 +08:00
< a href = "network-policy.html" >
2.2.19 NetworkPolicy
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4" data-path = "../guide/" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/" >
3. 用户指南
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.1" data-path = "../guide/resource-configuration.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/resource-configuration.html" >
2017-09-28 21:20:49 +08:00
3.1 资源对象配置
2017-08-21 17:44:43 +08:00
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.1.1" data-path = "../guide/configure-liveness-readiness-probes.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/configure-liveness-readiness-probes.html" >
3.1.1 配置Pod的liveness和readiness探针
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.1.2" data-path = "../guide/configure-pod-service-account.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/configure-pod-service-account.html" >
3.1.2 配置Pod的Service Account
< / a >
2017-09-28 21:20:49 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.1.3" data-path = "../guide/secret-configuration.html" >
2017-09-28 21:20:49 +08:00
< a href = "../guide/secret-configuration.html" >
3.1.3 Secret配置
< / a >
2017-10-10 14:51:45 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.1.4" data-path = "../guide/resource-quota-management.html" >
2017-10-10 14:51:45 +08:00
< a href = "../guide/resource-quota-management.html" >
3.2.3 管理namespace中的资源配额
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.2" data-path = "../guide/command-usage.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/command-usage.html" >
3.2 命令使用
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.2.1" data-path = "../guide/using-kubectl.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/using-kubectl.html" >
3.2.1 使用kubectl
< / a >
2017-09-16 20:56:43 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.2.2" data-path = "../guide/docker-cli-to-kubectl.html" >
2017-09-16 20:56:43 +08:00
< a href = "../guide/docker-cli-to-kubectl.html" >
3.2.2 docker用户过度到kubectl命令行指南
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.3" data-path = "../guide/cluster-security-management.html" >
2017-08-21 17:44:43 +08:00
2017-09-07 12:29:13 +08:00
< a href = "../guide/cluster-security-management.html" >
2017-08-21 17:44:43 +08:00
2017-09-07 12:29:13 +08:00
3.3 集群安全性管理
2017-08-21 17:44:43 +08:00
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.3.1" data-path = "../guide/managing-tls-in-a-cluster.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/managing-tls-in-a-cluster.html" >
3.3.1 管理集群中的TLS
< / a >
2017-08-21 18:44:34 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.3.2" data-path = "../guide/kubelet-authentication-authorization.html" >
2017-08-21 18:44:34 +08:00
< a href = "../guide/kubelet-authentication-authorization.html" >
3.3.2 kubelet的认证授权
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.3.3" data-path = "../guide/tls-bootstrapping.html" >
2017-08-21 18:44:34 +08:00
< a href = "../guide/tls-bootstrapping.html" >
3.3.3 TLS bootstrap
< / a >
2017-08-31 14:23:44 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.3.4" data-path = "../guide/kubectl-user-authentication-authorization.html" >
2017-08-31 14:23:44 +08:00
< a href = "../guide/kubectl-user-authentication-authorization.html" >
3.3.4 kubectl的用户认证授权
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.3.5" data-path = "../guide/rbac.html" >
2017-08-31 14:23:44 +08:00
< a href = "../guide/rbac.html" >
3.3.5 RBAC——基于角色的访问控制
< / a >
2017-09-07 14:13:59 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.3.6" data-path = "../guide/ip-masq-agent.html" >
2017-09-07 14:13:59 +08:00
< a href = "../guide/ip-masq-agent.html" >
3.3.6 IP伪装代理
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.4" data-path = "../guide/access-kubernetes-cluster.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/access-kubernetes-cluster.html" >
3.4 访问 Kubernetes 集群
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.4.1" data-path = "../guide/access-cluster.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/access-cluster.html" >
3.4.1 访问集群
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.4.2" data-path = "../guide/authenticate-across-clusters-kubeconfig.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/authenticate-across-clusters-kubeconfig.html" >
3.4.2 使用 kubeconfig 文件配置跨集群认证
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.4.3" data-path = "../guide/connecting-to-applications-port-forward.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/connecting-to-applications-port-forward.html" >
3.4.3 通过端口转发访问集群中的应用程序
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.4.4" data-path = "../guide/service-access-application-cluster.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/service-access-application-cluster.html" >
3.4.4 使用 service 访问群集中的应用程序
< / a >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.5" data-path = "../guide/application-development-deployment-flow.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/application-development-deployment-flow.html" >
3.5 在kubernetes中开发部署应用
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.5.1" data-path = "../guide/deploy-applications-in-kubernetes.html" >
2017-08-21 17:44:43 +08:00
< a href = "../guide/deploy-applications-in-kubernetes.html" >
3.5.1 适用于kubernetes的应用开发部署流程
< / a >
2017-08-21 18:44:34 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.4.5.2" data-path = "../guide/migrating-hadoop-yarn-to-kubernetes.html" >
2017-08-21 18:44:34 +08:00
< a href = "../guide/migrating-hadoop-yarn-to-kubernetes.html" >
3.5.2 迁移传统应用到kubernetes中——以Hadoop YARN为例
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5" data-path = "../practice/" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/" >
4. 最佳实践
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1" data-path = "../practice/install-kbernetes1.6-on-centos.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/install-kbernetes1.6-on-centos.html" >
4.1 在CentOS上部署kubernetes1.6集群
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.1" data-path = "../practice/create-tls-and-secret-key.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/create-tls-and-secret-key.html" >
4.1.1 创建TLS证书和秘钥
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.2" data-path = "../practice/create-kubeconfig.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/create-kubeconfig.html" >
4.1.2 创建kubeconfig文件
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.3" data-path = "../practice/etcd-cluster-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/etcd-cluster-installation.html" >
4.1.3 创建高可用etcd集群
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.4" data-path = "../practice/kubectl-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/kubectl-installation.html" >
4.1.4 安装kubectl命令行工具
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.5" data-path = "../practice/master-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/master-installation.html" >
4.1.5 部署master节点
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.6" data-path = "../practice/node-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/node-installation.html" >
4.1.6 部署node节点
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.7" data-path = "../practice/kubedns-addon-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/kubedns-addon-installation.html" >
4.1.7 安装kubedns插件
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.8" data-path = "../practice/dashboard-addon-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/dashboard-addon-installation.html" >
4.1.8 安装dashboard插件
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.9" data-path = "../practice/heapster-addon-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/heapster-addon-installation.html" >
4.1.9 安装heapster插件
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.1.10" data-path = "../practice/efk-addon-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/efk-addon-installation.html" >
4.1.10 安装EFK插件
< / a >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.2" data-path = "../practice/service-discovery-and-loadbalancing.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/service-discovery-and-loadbalancing.html" >
4.2 服务发现与负载均衡
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.2.1" data-path = "../practice/traefik-ingress-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/traefik-ingress-installation.html" >
4.2.1 安装Traefik ingress
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.2.2" data-path = "../practice/distributed-load-test.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/distributed-load-test.html" >
4.2.2 分布式负载测试
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.2.3" data-path = "../practice/network-and-cluster-perfermance-test.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/network-and-cluster-perfermance-test.html" >
4.2.3 网络和集群性能测试
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.2.4" data-path = "../practice/edge-node-configuration.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/edge-node-configuration.html" >
4.2.4 边缘节点配置
< / a >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3" data-path = "../practice/operation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/operation.html" >
4.3 运维管理
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.1" data-path = "../practice/service-rolling-update.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/service-rolling-update.html" >
4.3.1 服务滚动升级
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.2" data-path = "../practice/app-log-collection.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/app-log-collection.html" >
4.3.2 应用日志收集
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.3" data-path = "../practice/configuration-best-practice.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/configuration-best-practice.html" >
4.3.3 配置最佳实践
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.4" data-path = "../practice/monitor.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/monitor.html" >
4.3.4 集群及应用监控
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.5" data-path = "../practice/jenkins-ci-cd.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/jenkins-ci-cd.html" >
4.3.5 使用Jenkins进行持续构建与发布
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.6" data-path = "../practice/data-persistence-problem.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/data-persistence-problem.html" >
4.3.6 数据持久化问题
< / a >
2017-09-03 15:58:39 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.7" data-path = "../practice/manage-compute-resources-container.html" >
2017-09-03 15:58:39 +08:00
< a href = "../practice/manage-compute-resources-container.html" >
4.3.7 管理容器的计算资源
< / a >
2017-09-25 21:41:08 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.8" data-path = "../practice/using-prometheus-to-monitor-kuberentes-cluster.html" >
2017-09-25 21:41:08 +08:00
< a href = "../practice/using-prometheus-to-monitor-kuberentes-cluster.html" >
4.3.8 使用Prometheus监控kubernetes集群
< / a >
2017-10-16 17:36:01 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.9" data-path = "../practice/using-heapster-to-get-object-metrics.html" >
2017-10-16 17:36:01 +08:00
< a href = "../practice/using-heapster-to-get-object-metrics.html" >
4.3.9 使用Heapster获取集群和对象的metric数据
< / a >
2017-10-18 16:53:12 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.3.10" data-path = "../practice/manually-upgrade.html" >
2017-10-18 16:53:12 +08:00
< a href = "../practice/manually-upgrade.html" >
4.3.10 手动集群升级
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.4" data-path = "../practice/storage.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/storage.html" >
4.4 存储管理
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.4.1" data-path = "../practice/glusterfs.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/glusterfs.html" >
4.4.1 GlusterFS
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.4.1.1" data-path = "../practice/using-glusterfs-for-persistent-storage.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/using-glusterfs-for-persistent-storage.html" >
4.4.1.1 使用GlusterFS做持久化存储
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.4.1.2" data-path = "../practice/storage-for-containers-using-glusterfs-with-openshift.html" >
2017-08-21 17:44:43 +08:00
< a href = "../practice/storage-for-containers-using-glusterfs-with-openshift.html" >
4.4.1.2 在OpenShift中使用GlusterFS做持久化存储
< / a >
2017-09-01 21:04:51 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.4.2" data-path = "../practice/cephfs.html" >
2017-09-01 21:04:51 +08:00
< a href = "../practice/cephfs.html" >
4.4.2 CephFS
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.4.2.1" data-path = "../practice/using-ceph-for-persistent-storage.html" >
2017-09-01 21:04:51 +08:00
< a href = "../practice/using-ceph-for-persistent-storage.html" >
4.4.2.1 使用Ceph做持久化存储
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
< / ul >
2017-10-19 15:31:08 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.5.5" data-path = "../practice/services-management-tool.html" >
2017-10-19 15:31:08 +08:00
< a href = "../practice/services-management-tool.html" >
4.5 服务编排管理
< / a >
2017-10-20 16:22:43 +08:00
< ul class = "articles" >
< li class = "chapter " data-level = "1.5.5.1" data-path = "../practice/helm.html" >
< a href = "../practice/helm.html" >
4.5.1 Helm
< / a >
< / li >
< / ul >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6" data-path = "../usecases/" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/" >
5. 领域应用
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.1" data-path = "../usecases/microservices.html" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/microservices.html" >
5.1 微服务架构
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.1.1" data-path = "../usecases/service-discovery-in-microservices.html" >
2017-09-20 21:55:19 +08:00
< a href = "../usecases/service-discovery-in-microservices.html" >
5.1.1 微服务中的服务发现
< / a >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.2" data-path = "../usecases/service-mesh.html" >
2017-09-20 21:55:19 +08:00
< a href = "../usecases/service-mesh.html" >
5.2 Service Mesh 服务网格
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.2.1" data-path = "../usecases/istio.html" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/istio.html" >
5.1.1 Istio
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.2.1.1" data-path = "../usecases/istio-installation.html" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/istio-installation.html" >
5.1.1.1 安装istio
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.2.1.2" data-path = "../usecases/configuring-request-routing.html" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/configuring-request-routing.html" >
5.1.1.2 配置请求的路由规则
< / a >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.2.2" data-path = "../usecases/linkerd.html" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/linkerd.html" >
5.1.2 Linkerd
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.2.2.1" data-path = "../usecases/linkerd-user-guide.html" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/linkerd-user-guide.html" >
5.1.2.1 Linkerd 使用指南
< / a >
< / li >
< / ul >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.3" data-path = "../usecases/big-data.html" >
2017-08-21 17:44:43 +08:00
< a href = "../usecases/big-data.html" >
5.2 大数据
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.3.1" data-path = "../usecases/spark-standalone-on-kubernetes.html" >
2017-08-21 17:44:43 +08:00
2017-08-30 14:20:52 +08:00
< a href = "../usecases/spark-standalone-on-kubernetes.html" >
2017-08-21 17:44:43 +08:00
2017-08-30 14:20:52 +08:00
5.2.1 Spark standalone on Kubernetes
2017-08-21 17:44:43 +08:00
< / a >
2017-08-31 14:23:44 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.3.2" data-path = "../usecases/running-spark-with-kubernetes-native-scheduler.html" >
2017-08-31 14:23:44 +08:00
2017-09-14 15:57:50 +08:00
< a href = "../usecases/running-spark-with-kubernetes-native-scheduler.html" >
2017-08-31 14:23:44 +08:00
5.2.2 运行支持kubernetes原生调度的Spark程序
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
2017-08-30 16:52:33 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.6.4" data-path = "../usecases/serverless.html" >
2017-08-30 16:52:33 +08:00
< a href = "../usecases/serverless.html" >
5.3 Serverless架构
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.7" data-path = "../develop/" >
2017-08-21 17:44:43 +08:00
< a href = "../develop/" >
6. 开发指南
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.7.1" data-path = "../develop/developing-environment.html" >
2017-08-21 17:44:43 +08:00
< a href = "../develop/developing-environment.html" >
6.1 开发环境搭建
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.7.2" data-path = "../develop/testing.html" >
2017-08-21 17:44:43 +08:00
< a href = "../develop/testing.html" >
6.2 单元测试和集成测试
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.7.3" data-path = "../develop/client-go-sample.html" >
2017-08-21 17:44:43 +08:00
< a href = "../develop/client-go-sample.html" >
6.3 client-go示例
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.7.4" data-path = "../develop/contribute.html" >
2017-08-21 17:44:43 +08:00
< a href = "../develop/contribute.html" >
6.4 社区贡献
< / a >
< / li >
< / ul >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.8" data-path = "../appendix/" >
2017-08-21 17:44:43 +08:00
< a href = "../appendix/" >
7. 附录
< / a >
< ul class = "articles" >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.8.1" data-path = "../appendix/docker-best-practice.html" >
2017-08-21 17:44:43 +08:00
< a href = "../appendix/docker-best-practice.html" >
7.1 Docker最佳实践
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.8.2" data-path = "../appendix/issues.html" >
2017-08-21 17:44:43 +08:00
< a href = "../appendix/issues.html" >
7.2 问题记录
< / a >
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.8.3" data-path = "../appendix/tricks.html" >
2017-08-21 17:44:43 +08:00
< a href = "../appendix/tricks.html" >
7.3 使用技巧
< / a >
2017-09-21 15:00:54 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.8.4" data-path = "../appendix/debug-kubernetes-services.html" >
2017-09-21 15:00:54 +08:00
< a href = "../appendix/debug-kubernetes-services.html" >
7.4 kubernetes service中的故障排查
< / a >
2017-10-18 14:16:55 +08:00
< / li >
2017-10-20 10:51:14 +08:00
< li class = "chapter " data-level = "1.8.5" data-path = "../appendix/material-share.html" >
2017-10-18 14:16:55 +08:00
< a href = "../appendix/material-share.html" >
2017-10-18 16:53:12 +08:00
7.5 Kubernetes相关资讯和情报链接
2017-10-18 14:16:55 +08:00
< / a >
2017-08-21 17:44:43 +08:00
< / li >
< / ul >
< / li >
< li class = "divider" > < / li >
< li >
< a href = "https://www.gitbook.com" target = "blank" class = "gitbook-link" >
2017-09-19 22:01:07 +08:00
本书使用 GitBook 发布
2017-08-21 17:44:43 +08:00
< / a >
< / li >
< / ul >
< / nav >
< / div >
< div class = "book-body" >
< div class = "body-inner" >
< div class = "book-header" role = "navigation" >
<!-- Title -->
< h1 >
< i class = "fa fa-circle-o-notch fa-spin" > < / i >
< a href = ".." > 2.2.16 Horizontal Pod Autoscaling< / a >
< / h1 >
< / div >
< div class = "page-wrapper" tabindex = "-1" role = "main" >
< div class = "page-inner" >
< div class = "search-plus" id = "book-search-results" >
< div class = "search-noresults" >
< section class = "normal markdown-section" >
< h1 id = "horizontal-pod-autoscaling" > Horizontal Pod Autoscaling< / h1 >
< p > 应 用 的 资 源 使 用 率 通 常 都 有 高 峰 和 低 谷 的 时 候 , 如 何 削 峰 填 谷 , 提 高 集 群 的 整 体 资 源 利 用 率 , 让 service中 的 Pod个 数 自 动 调 整 呢 ? 这 就 有 赖 于 Horizontal Pod Autoscaling了 , 顾 名 思 义 , 使 Pod水 平 自 动 缩 放 。 这 个 Object( 跟 Pod、 Deployment一 样 都 是 API resource) 也 是 最 能 体 现 kubernetes之 于 传 统 运 维 价 值 的 地 方 , 不 再 需 要 手 动 扩 容 了 , 终 于 实 现 自 动 化 了 , 还 可 以 自 定 义 指 标 , 没 准 未 来 还 可 以 通 过 人 工 智 能 自 动 进 化 呢 ! < / p >
< p > Horizontal Pod Autoscaling仅 适 用 于 Deployment和 ReplicationController( ReplicaSet已 经 被 ReplicationController取 代 ) , 在 V1版 本 中 仅 支 持 根 据 Pod的 CPU利 用 率 扩 所 容 , 在 v1alpha版 本 中 , 支 持 根 据 内 存 和 用 户 自 定 义 的 metric扩 缩 容 。 < / p >
< p > 如 果 你 不 想 看 下 面 的 文 章 可 以 直 接 看 下 面 的 示 例 图 , 组 件 交 互 、 组 件 的 配 置 、 命 令 示 例 , 都 画 在 图 上 了 。 < / p >
< p > Horizontal Pod Autoscaling由 API server和 controller共 同 实 现 。 < / p >
2017-10-20 10:51:14 +08:00
< figure id = "fig1.3.2.16.1" > < img src = "../images/horizontal-pod-autoscaler.png" alt = "horizontal-pod-autoscaler" > < figcaption > 图 片 - horizontal-pod-autoscaler< / figcaption > < / figure >
2017-08-21 17:44:43 +08:00
< h2 id = "metrics支持" > Metrics支 持 < / h2 >
2017-08-29 10:29:47 +08:00
< p > 在 不 同 版 本 的 API中 , HPA autoscale时 可 以 根 据 以 下 指 标 来 判 断 : < / p >
2017-08-21 17:44:43 +08:00
< ul >
< li > autoscaling/v1< ul >
< li > CPU< / li >
< / ul >
< / li >
< li > autoscaling/v2alpha1< ul >
< li > 内 存 < / li >
< li > 自 定 义 metrics< ul >
< li > kubernetes1.6起 支 持 自 定 义 metrics, 但 是 必 须 在 kube-controller-manager中 配 置 如 下 两 项 : < ul >
< li > < code > --horizontal-pod-autoscaler-use-rest-clients=true< / code > < / li >
< li > < code > --api-server< / code > 指 向 < a href = "https://github.com/kubernetes/kube-aggregator" target = "_blank" > kube-aggregator< / a > , 也 可 以 使 用 heapster来 实 现 , 通 过 在 启 动 heapster的 时 候 指 定 < code > --api-server=true< / code > 。 查 看 < a href = "https://github.com/kubernetes/metrics" target = "_blank" > kubernetes metrics< / a > < / li >
< / ul >
< / li >
< / ul >
< / li >
< li > 多 种 metrics组 合 < ul >
< li > HPA会 根 据 每 个 metric的 值 计 算 出 scale的 值 , 并 将 最 大 的 那 个 指 作 为 扩 容 的 最 终 结 果 。 < / li >
< / ul >
< / li >
< / ul >
< / li >
< / ul >
< h2 id = "使用kubectl管理" > 使 用 kubectl管 理 < / h2 >
< p > Horizontal Pod Autoscaling作 为 API resource也 可 以 像 Pod、 Deployment一 样 使 用 kubeclt命 令 管 理 , 使 用 方 法 跟 它 们 一 样 , 资 源 名 称 为 < code > hpa< / code > 。 < / p >
2017-10-16 17:36:01 +08:00
< pre > < code class = "lang-bash" > kubectl create hpa
2017-10-18 14:16:55 +08:00
kubectl get hpa
2017-08-21 17:44:43 +08:00
kubectl describe hpa
kubectl delete hpa
2017-10-16 17:36:01 +08:00
< / code > < / pre >
< p > 有 一 点 不 同 的 是 , 可 以 直 接 使 用 < code > kubectl autoscale< / code > 直 接 通 过 命 令 行 的 方 式 创 建 Horizontal Pod Autoscaler。 < / p >
2017-08-21 17:44:43 +08:00
< p > 用 法 如 下 : < / p >
2017-10-16 17:36:01 +08:00
< pre > < code class = "lang-bash" > kubectl autoscale (< span class = "hljs-_" > -f< / span > FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS
2017-08-21 17:44:43 +08:00
[--cpu-percent=CPU] [flags] [options]
< / code > < / pre >
< p > 举 个 例 子 : < / p >
2017-10-16 17:36:01 +08:00
< pre > < code class = "lang-bash" > kubectl autoscale deployment foo --min=2 --max=5 --cpu-percent=80
< / code > < / pre >
< p > 为 Deployment foo创 建 一 个 autoscaler, 当 Pod的 CPU利 用 率 达 到 80%的 时 候 , RC的 replica数 在 2到 5之 间 。 该 命 令 的 详 细 使 用 文 档 见 < a href = "https://kubernetes.io/docs/user-guide/kubectl/v1.6/#autoscale" target = "_blank" > https://kubernetes.io/docs/user-guide/kubectl/v1.6/#autoscale< / a > 。 < / p >
2017-08-21 17:44:43 +08:00
< p > < strong > 注 意 < / strong > : 如 果 为 ReplicationController创 建 HPA的 话 , 无 法 使 用 rolling update, 但 是 对 于 Deployment来 说 是 可 以 的 , 因 为 Deployment在 执 行 rolling update的 时 候 会 自 动 创 建 新 的 ReplicationController。 < / p >
< h2 id = "什么是-horizontal-pod-autoscaling?" > 什 么 是 Horizontal Pod Autoscaling? < / h2 >
< p > 利 用 Horizontal Pod Autoscaling, kubernetes 能 够 根 据 监 测 到 的 CPU 利 用 率 ( 或 者 在 alpha 版 本 中 支 持 的 应 用 提 供 的 metric) 自 动 的 扩 容 replication controller, deployment 和 replica set。 < / p >
< p > Horizontal Pod Autoscaler 作 为 kubernetes API resource 和 controller 的 实 现 。 Resource 确 定 controller 的 行 为 。 Controller 会 根 据 监 测 到 用 户 指 定 的 目 标 的 CPU 利 用 率 周 期 性 得 调 整 replication controller 或 deployment 的 replica 数 量 。 < / p >
< h2 id = "horizontal-pod-autoscaler-如何工作?" > Horizontal Pod Autoscaler 如 何 工 作 ? < / h2 >
< p > Horizontal Pod Autoscaler 由 一 个 控 制 循 环 实 现 , 循 环 周 期 由 controller manager 中 的 < code > --horizontal-pod-autoscaler-sync-period< / code > 标 志 指 定 ( 默 认 是 30 秒 ) 。 < / p >
< p > 在 每 个 周 期 内 , controller manager 会 查 询 HorizontalPodAutoscaler 中 定 义 的 metric 的 资 源 利 用 率 。 Controller manager 从 resource metric API( 每 个 pod 的 resource metric) 或 者 自 定 义 metric API( 所 有 的 metric) 中 获 取 metric。 < / p >
< ul >
< li > 每 个 Pod 的 resource metric( 例 如 CPU) , controller 通 过 resource metric API 获 取 HorizontalPodAutoscaler 中 定 义 的 每 个 Pod 中 的 metric。 然 后 , 如 果 设 置 了 目 标 利 用 率 , controller 计 算 利 用 的 值 与 每 个 Pod 的 容 器 里 的 resource request 值 的 百 分 比 。 如 果 设 置 了 目 标 原 始 值 , 将 直 接 使 用 该 原 始 metric 值 。 然 后 controller 计 算 所 有 目 标 Pod 的 利 用 率 或 原 始 值 ( 取 决 于 所 指 定 的 目 标 类 型 ) 的 平 均 值 , 产 生 一 个 用 于 缩 放 所 需 replica 数 量 的 比 率 。 请 注 意 , 如 果 某 些 Pod 的 容 器 没 有 设 置 相 关 的 resource request , 则 不 会 定 义 Pod 的 CPU 利 用 率 , 并 且 Aucoscaler 也 不 会 对 该 metric 采 取 任 何 操 作 。 有 关 自 动 缩 放 算 法 如 何 工 作 的 更 多 细 节 , 请 参 阅 < a href = "https://git.k8s.io/community/contributors/design-proposals/horizontal-pod-autoscaler.md#autoscaling-algorithm" target = "_blank" > 自 动 缩 放 算 法 设 计 文 档 < / a > 。 < / li >
< li > 对 于 每 个 Pod 自 定 义 的 metric, controller 功 能 类 似 于 每 个 Pod 的 resource metric, 只 是 它 使 用 原 始 值 而 不 是 利 用 率 值 。 < / li >
< li > 对 于 object metric, 获 取 单 个 度 量 ( 描 述 有 问 题 的 对 象 ) , 并 与 目 标 值 进 行 比 较 , 以 产 生 如 上 所 述 的 比 率 。 < / li >
< / ul >
< p > HorizontalPodAutoscaler 控 制 器 可 以 以 两 种 不 同 的 方 式 获 取 metric : 直 接 的 Heapster 访 问 和 REST 客 户 端 访 问 。 < / p >
< p > 当 使 用 直 接 的 Heapster 访 问 时 , HorizontalPodAutoscaler 直 接 通 过 API 服 务 器 的 服 务 代 理 子 资 源 查 询 Heapster。 需 要 在 集 群 上 部 署 Heapster 并 在 kube-system namespace 中 运 行 。 < / p >
< p > 有 关 REST 客 户 端 访 问 的 详 细 信 息 , 请 参 阅 < a href = "https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale.md#prerequisites" target = "_blank" > 支 持 自 定 义 度 量 < / a > 。 < / p >
< p > Autoscaler 访 问 相 应 的 replication controller, deployment 或 replica set 来 缩 放 子 资 源 。 < / p >
< p > Scale 是 一 个 允 许 您 动 态 设 置 副 本 数 并 检 查 其 当 前 状 态 的 接 口 。 < / p >
< p > 有 关 缩 放 子 资 源 的 更 多 细 节 可 以 在 < a href = "https://git.k8s.io/community/contributors/design-proposals/horizontal-pod-autoscaler.md#scale-subresource" target = "_blank" > 这 里 < / a > 找 到 。 < / p >
< h2 id = "api-object" > API Object< / h2 >
< p > Horizontal Pod Autoscaler 是 kubernetes 的 < code > autoscaling< / code > API 组 中 的 API 资 源 。 当 前 的 稳 定 版 本 中 , 只 支 持 CPU 自 动 扩 缩 容 , 可 以 在 < code > autoscaling/v1< / code > API 版 本 中 找 到 。 < / p >
< p > 在 alpha 版 本 中 支 持 根 据 内 存 和 自 定 义 metric 扩 缩 容 , 可 以 在 < code > autoscaling/v2alpha1< / code > 中 找 到 。 < code > autoscaling/v2alpha1< / code > 中 引 入 的 新 字 段 在 < code > autoscaling/v1< / code > 中 是 做 为 annotation 而 保 存 的 。 < / p >
< p > 关 于 该 API 对 象 的 更 多 信 息 , 请 参 阅 < a href = "https://git.k8s.io/community/contributors/design-proposals/horizontal-pod-autoscaler.md#horizontalpodautoscaler-object" target = "_blank" > HorizontalPodAutoscaler Object< / a > 。 < / p >
< h2 id = "在-kubectl-中支持-horizontal-pod-autoscaling" > 在 kubectl 中 支 持 Horizontal Pod Autoscaling< / h2 >
< p > Horizontal Pod Autoscaler 和 其 他 的 所 有 API 资 源 一 样 , 通 过 < code > kubectl< / code > 以 标 准 的 方 式 支 持 。 < / p >
< p > 我 们 可 以 使 用 < code > kubectl create< / code > 命 令 创 建 一 个 新 的 autoscaler。 < / p >
< p > 我 们 可 以 使 用 < code > kubectl get hpa< / code > 列 出 所 有 的 autoscaler, 使 用 < code > kubectl describe hpa< / code > 获 取 其 详 细 信 息 。 < / p >
< p > 最 后 我 们 可 以 使 用 < code > kubectl delete hpa< / code > 删 除 autoscaler。 < / p >
< p > 另 外 , 可 以 使 用 < code > kubectl autoscale< / code > 命 令 , 很 轻 易 的 就 可 以 创 建 一 个 Horizontal Pod Autoscaler。 < / p >
< p > 例 如 , 执 行 < code > kubectl autoscale rc foo — min=2 — max=5 — cpu-percent=80< / code > 命 令 将 为 replication controller < em > foo< / em > 创 建 一 个 autoscaler, 目 标 的 CPU 利 用 率 是 < code > 80%< / code > , replica 的 数 量 介 于 2 和 5 之 间 。 < / p >
< p > 关 于 < code > kubectl autoscale< / code > 的 更 多 信 息 请 参 阅 < a href = "https://kubernetes.io/docs/user-guide/kubectl/v1.6/#autoscale" target = "_blank" > 这 里 < / a > 。 < / p >
< h2 id = "滚动更新期间的自动扩缩容" > 滚 动 更 新 期 间 的 自 动 扩 缩 容 < / h2 >
< p > 目 前 在 Kubernetes中 , 可 以 通 过 直 接 管 理 replication controller 或 使 用 deployment 对 象 来 执 行 < a href = "https://kubernetes.io/docs/tasks/run-application/rolling-update-replication-controller" target = "_blank" > 滚 动 更 新 < / a > , 该 deployment 对 象 为 您 管 理 基 础 replication controller。 < / p >
< p > Horizontal Pod Autoscaler 仅 支 持 后 一 种 方 法 : Horizontal Pod Autoscaler 被 绑 定 到 deployment 对 象 , 它 设 置 deployment 对 象 的 大 小 , deployment 负 责 设 置 底 层 replication controller 的 大 小 。 < / p >
< p > Horizontal Pod Autoscaler 不 能 使 用 直 接 操 作 replication controller 进 行 滚 动 更 新 , 即 不 能 将 Horizontal Pod Autoscaler 绑 定 到 replication controller, 并 进 行 滚 动 更 新 ( 例 如 使 用 < code > kubectl rolling-update< / code > ) 。 < / p >
< p > 这 不 行 的 原 因 是 , 当 滚 动 更 新 创 建 一 个 新 的 replication controller 时 , Horizontal Pod Autoscaler 将 不 会 绑 定 到 新 的 replication controller 上 。 < / p >
< h2 id = "支持多个-metric" > 支 持 多 个 metric< / h2 >
< p > Kubernetes 1.6 中 增 加 了 支 持 基 于 多 个 metric 的 扩 缩 容 。 您 可 以 使 用 < code > autoscaling/v2alpha1< / code > API 版 本 来 为 Horizontal Pod Autoscaler 指 定 多 个 metric。 然 后 Horizontal Pod Autoscaler controller 将 权 衡 每 一 个 metric, 并 根 据 该 metric 提 议 一 个 新 的 scale。 在 所 有 提 议 里 最 大 的 那 个 scale 将 作 为 最 终 的 scale。 < / p >
< h2 id = "支持自定义-metric" > 支 持 自 定 义 metric< / h2 >
< p > < strong > 注 意 : < / strong > Kubernetes 1.2 根 据 特 定 于 应 用 程 序 的 metric , 通 过 使 用 特 殊 注 释 的 方 式 , 增 加 了 对 缩 放 的 alpha 支 持 。 < / p >
< p > 在 Kubernetes 1.6中 删 除 了 对 这 些 注 释 的 支 持 , 有 利 于 < code > autoscaling/v2alpha1< / code > API。 虽 然 旧 的 收 集 自 定 义 metric 的 旧 方 法 仍 然 可 用 , 但 是 这 些 metric 将 不 可 供 Horizontal Pod Autoscaler 使 用 , 并 且 用 于 指 定 要 缩 放 的 自 定 义 metric 的 以 前 的 注 释 也 不 在 受 Horizontal Pod Autoscaler 认 可 。 < / p >
< p > Kubernetes 1.6增 加 了 在 Horizontal Pod Autoscale r中 使 用 自 定 义 metric 的 支 持 。 < / p >
< p > 您 可 以 为 < code > autoscaling/v2alpha1< / code > API 中 使 用 的 Horizontal Pod Autoscaler 添 加 自 定 义 metric 。 < / p >
< p > Kubernetes 然 后 查 询 新 的 自 定 义 metric API 来 获 取 相 应 自 定 义 metric 的 值 。 < / p >
< h2 id = "前提条件" > 前 提 条 件 < / h2 >
< p > 为 了 在 Horizontal Pod Autoscaler 中 使 用 自 定 义 metric, 您 必 须 在 您 集 群 的 controller manager 中 将 < code > --horizontal-pod-autoscaler-use-rest-clients< / code > 标 志 设 置 为 true。 然 后 , 您 必 须 通 过 将 controller manager 的 目 标 API server 设 置 为 API server aggregator( 使 用 < code > --apiserver< / code > 标 志 ) , 配 置 您 的 controller manager 通 过 API server aggregator 与 API server 通 信 。 Resource metric API和 自 定 义 metric API 也 必 须 向 API server aggregator 注 册 , 并 且 必 须 由 集 群 上 运 行 的 API server 提 供 。 < / p >
< p > 您 可 以 使 用 Heapster 实 现 resource metric API, 方 法 是 将 < code > --api-server< / code > 标 志 设 置 为 true 并 运 行 Heapster。 单 独 的 组 件 必 须 提 供 自 定 义 metric API( 有 关 自 定 义 metric API的 更 多 信 息 , 可 从 < a href = "https://github.com/kubernetes/metrics" target = "_blank" > k8s.io/metrics repository< / a > 获 得 ) 。 < / p >
< h2 id = "进一步阅读" > 进 一 步 阅 读 < / h2 >
< ul >
< li > 设 计 文 档 : < a href = "https://git.k8s.io/community/contributors/design-proposals/horizontal-pod-autoscaler.md" target = "_blank" > Horizontal Pod Autoscaling< / a > < / li >
< li > kubectl autoscale 命 令 : < a href = "https://kubernetes.io/docs/user-guide/kubectl/v1.6/#autoscale" target = "_blank" > kubectl autoscale< / a > < / li >
< li > 使 用 例 子 : < a href = "https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough" target = "_blank" > Horizontal Pod Autoscaler< / a > < / li >
< / ul >
< h2 id = "参考" > 参 考 < / h2 >
< p > HPA设 计 文 档 : < a href = "https://github.com/kubernetes/community/blob/master/contributors/design-proposals/horizontal-pod-autoscaler.md" target = "_blank" > https://github.com/kubernetes/community/blob/master/contributors/design-proposals/horizontal-pod-autoscaler.md< / a > < / p >
< p > HPA说 明 : < a href = "https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" target = "_blank" > https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/< / a > < / p >
< p > HPA详 解 : < a href = "https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/" target = "_blank" > https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/< / a > < / p >
< p > kubectl autoscale命 令 详 细 使 用 说 明 : < a href = "https://kubernetes.io/docs/user-guide/kubectl/v1.6/#autoscale" target = "_blank" > https://kubernetes.io/docs/user-guide/kubectl/v1.6/#autoscale< / a > < / p >
2017-10-18 14:16:55 +08:00
< p > 自 定 义 metrics开 发 : < a href = "https://github.com/kubernetes/metrics" target = "_blank" > https://github.com/kubernetes/metrics< / a > < / p >
2017-10-09 15:28:05 +08:00
< footer class = "page-footer" > < span class = "copyright" > Copyright © jimmysong.io 2017 all right reserved, powered by Gitbook< / span > < span class = "footer-modification" > Updated:
2017-10-18 14:16:55 +08:00
2017-10-17 14:51:31
2017-10-09 15:28:05 +08:00
< / span > < / footer >
2017-08-21 17:44:43 +08:00
< / section >
< / div >
< div class = "search-results" >
< div class = "has-results" >
< h1 class = "search-results-title" > < span class = 'search-results-count' > < / span > results matching "< span class = 'search-query' > < / span > "< / h1 >
< ul class = "search-results-list" > < / ul >
< / div >
< div class = "no-results" >
< h1 class = "search-results-title" > No results matching "< span class = 'search-query' > < / span > "< / h1 >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< a href = "configmap.html" class = "navigation navigation-prev " aria-label = "Previous page: 2.2.15 ConfigMap" >
< i class = "fa fa-angle-left" > < / i >
< / a >
< a href = "label.html" class = "navigation navigation-next " aria-label = "Next page: 2.2.17 Label" >
< i class = "fa fa-angle-right" > < / i >
< / a >
< / div >
< script >
var gitbook = gitbook || [];
gitbook.push(function() {
2017-10-22 22:34:11 +08:00
gitbook.page.hasChanged({"page":{"title":"2.2.16 Horizontal Pod Autoscaling","level":"1.3.2.16","depth":3,"next":{"title":"2.2.17 Label","level":"1.3.2.17","depth":3,"path":"concepts/label.md","ref":"concepts/label.md","articles":[]},"previous":{"title":"2.2.15 ConfigMap","level":"1.3.2.15","depth":3,"path":"concepts/configmap.md","ref":"concepts/configmap.md","articles":[]},"dir":"ltr"},"config":{"plugins":["github","codesnippet","splitter","page-toc-button","image-captions","editlink","back-to-top-button","-lunr","-search","search-plus","github-buttons@2.1.0","favicon@^0.0.2","tbfed-pagefooter@^0.0.1","3-ba"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © jimmysong.io 2017","modify_label":"Updated:","modify_format":"YYYY-MM-DD HH:mm:ss"},"github":{"url":"https://github.com/rootsongjc/kubernetes-handbook"},"editlink":{"label":"编辑本页","multilingual":false,"base":"https://github.com/rootsongjc/kubernetes-handbook/blob/master/"},"splitter":{},"codesnippet":{},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"favicon":{"shortcut":"favicon.ico","bookmark":"favicon.ico"},"page-toc-button":{},"back-to-top-button":{},"github-buttons":{"repo":"rootsongjc/kubernetes-handbook","types":["star"],"size":"small"},"3-ba":{"configuration":"auto","token":"11f7d254cfa4e0ca44b175c66d379ecc"},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"search-plus":{},"image-captions":{"caption":"图片 - _CAPTION_","variable_name":"_pictures"}},"theme":"default","author":"Jimmy Song","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[{"backlink":"cloud-native/kubernetes-and-cloud-native-app-overview.html#fig1.2.1","level":"1.2","list_caption":"Figure: 云计算演进历程","alt":"云计算演进历程","nro":1,"url":"../images/cloud-computing-evolution-road.jpg","index":1,"caption_template":"图片 - _CAPTION_","label":"云计算演进历程","attributes":{},"skip":false,"key":"1.2.1"},{"backlink":"cloud-native/kubernetes-and-cloud-native-app-overview.html#fig1.2.2","level":"1.2","list_caption":"Figure: Cloud native思维导图","alt":"Cloud native思维导图","nro":2,"url":"../images/cloud-native-architecutre-mindnode.jpg","index":2,"caption_template":"图片 - _CAPTION_","label":"Cloud native思维导图","attributes":{},"skip":false,"key":"1.2.2"},{"backlink":"cloud-native/kubernetes-and-cloud-native-app-overview.html#fig1.2.3","level":"1.2","list_caption":"Figure: 十二因素应用","alt":"十二因素应用","nro":3,"url":"../images/12-factor-app.png","index":3,"caption_template":"图片 - _CAPTION_","label":"十二因素应用","attributes":{},"skip":false,"key":"1.2.3"},{"backlink":"cloud-native/kubernetes-and-cloud-native-app-overview.html#fig1.2.4","level":"1.2","list_caption":"Figure: 使用Jenkins进行持续集成与发布流程图","alt":"使用Jenkins进行持续集成与发布流程图","nro":4,"url":"../images/kubernetes-jenkins-ci-cd.png","index":4,"caption_template":"图片 - _CAPTION_","label":"使用Jenkins进行持续集成与发布流程图","attributes":{},"skip":false,"key":"1.2.4"},{"backlink":"cloud-native/kubernetes-and-cloud-native-app-overview.html#fig1.2.5","level":"1.2","list_caption":"Figure: filebeat日志收集架构图","alt":"filebeat日志收集架构图","nro":5,"url":"../images/filebeat-log-collector-arch.png","index":5,
2017-08-21 17:44:43 +08:00
});
< / script >
< / div >
< script src = "../gitbook/gitbook.js" > < / script >
< script src = "../gitbook/theme.js" > < / script >
< script src = "../gitbook/gitbook-plugin-github/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-splitter/splitter.js" > < / script >
< script src = "../gitbook/gitbook-plugin-page-toc-button/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-editlink/plugin.js" > < / script >
2017-09-19 21:38:03 +08:00
< script src = "../gitbook/gitbook-plugin-back-to-top-button/plugin.js" > < / script >
2017-08-21 17:44:43 +08:00
< script src = "../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js" > < / script >
< script src = "../gitbook/gitbook-plugin-search-plus/search.js" > < / script >
2017-10-09 15:28:05 +08:00
< script src = "../gitbook/gitbook-plugin-github-buttons/plugin.js" > < / script >
2017-10-11 18:13:13 +08:00
< script src = "../gitbook/gitbook-plugin-3-ba/plugin.js" > < / script >
2017-08-21 17:44:43 +08:00
< script src = "../gitbook/gitbook-plugin-sharing/buttons.js" > < / script >
< script src = "../gitbook/gitbook-plugin-fontsettings/fontsettings.js" > < / script >
< / body >
< / html >