19.06.2021 Views

148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13 ■ Using Autoscaling

Table 13-1. HorizontalPodAutoscaler Spec Fields

Field

Description

scaleTargetRef

The target resource to be scaled. Can be a Deployment,

ReplicaSet or ReplicationController.

minReplicas The minimum number of pods. Default is 1.

maxReplicas

The maximum number of pods. Cannot be less than

minReplicas.

targetCPUUtilizationPercentage

The target average CPU utilization. If not specified, a default

autoscaler policy is used,

The kubectl autoscale command has the following syntax, which essentially provides the same

settings as the specification.

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

[--cpu-percent=CPU] [flags]

Some of the options supported by kubectl autoscale are as discussed in Table 13-2.

Table 13-2. kubectl autoscale Options

Option Description Default Value Required (explicit

or default)

--cpu-percent

-f, --filename

--max

--min

--name

The target average

CPU utilization over

all the pods in the

resource represented

as a percentage of the

CPU requests. If not set

or negative, a default

autoscaling policy is

used.

File name, directory, or

URL for the resource to

autoscale.

Upper limit for the

number of pods.

Lower limit for the

number of pods. If not

specified or –ve a default

value is used.

The name of the newly

created object.

-1 Yes

[] Yes

-1 Yes

-1 Yes

“” No

Using the kubectl autoscale command, create a horizontal pod autoscaler. Set target CPU utilization

to 100% and set minimum number of pods to 3 and maximum number of pods to 10.

304

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!