• 欢迎访问蜷缩的蜗牛博客 蜷缩的蜗牛
  • 微信搜索: 蜷缩的蜗牛 | 联系站长 kbsonlong@qq.com
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

kubectl autoscale(Pod水平自动伸缩)

kubectl命令表 蜷缩的蜗牛 3个月前 (06-20) 15次浏览 已收录

kubectl autoscale

使用 autoscaler 自动设置在 kubernetes 集群中运行的 pod 数量(水平自动伸缩)。

指定 Deployment、ReplicaSet 或 ReplicationController,并创建已经定义好资源的自动伸缩器。使用自动伸缩器可以根据需要自动增加或减少系统中部署的 pod 数量。

语法

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

示例

使用 Deployment “foo”设定,使用默认的自动伸缩策略,指定目标 CPU 使用率,使其 Pod 数量在 2 到 10 之间。

kubectl autoscale deployment foo --min=2 --max=10

使用 RC“foo”设定,使其 Pod 的数量介于 1 和 5 之间,CPU 使用率维持在 80%。

kubectl autoscale rc foo --max=5 --cpu-percent=80

Flags

Name Shorthand Default Usage
allow-missing-template-keys true If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
cpu-percent -1 The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it’s not specified or negative, a default autoscaling policy will be used.
dry-run false If true, only print the object that would be sent, without sending it.
filename f [] Filename, directory, or URL to files identifying the resource to autoscale.
generator horizontalpodautoscaler/v1 The name of the API generator to use. Currently there is only 1 generator.
include-extended-apis true If true, include definitions of new APIs via calls to the API server. [default true]
max -1 The upper limit for the number of pods that can be set by the autoscaler. Required.
min -1 The lower limit for the number of pods that can be set by the autoscaler. If it’s not specified or negative, the server will apply a default value.
name The name for the newly created object. If not specified, the name of the input resource will be used.
no-headers false When using the default or custom-column output format, don’t print headers (default print headers).
output o Output format. One of: json|yaml|wide|name|custom-columns=…|custom-columns-file=…|go-template=…|go-template-file=…|jsonpath=…|jsonpath-file=… See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-version DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: ‘jobs.v1.batch/myjob’).
record false Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursive R false Process the directory used in -f, –filename recursively. Useful when you want to manage related manifests organized within the same directory.
save-config false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-all a false When printing, show all resources (default hide terminated pods.)
show-labels false When printing, show all labels as the last column (default hide labels column)
sort-by If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. ‘{.metadata.name}’). The field in the API resource specified by this JSONPath expression must be an integer or a string.
template Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].

 

K8S 中文社区微信公众号

本文转载自 kubectl autoscale(Pod 水平自动伸缩)


蜷缩的蜗牛 , 版权所有丨如未注明 , 均为原创丨 转载请注明kubectl autoscale(Pod 水平自动伸缩)
喜欢 (0)
[]
分享 (0)