Commit Graph

147 Commits

Author SHA1 Message Date
Pavel Beschetnov
caddfdd040 Add pod ambiguous selector check 2022-11-04 12:49:20 +00:00
Zbynek Roubalik
1cefcdea2d add --concurrent-horizontal-pod-autoscaler-syncs flag to kube-controller-manager
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
2022-10-17 17:39:31 +02:00
Kubernetes Prow Robot
da6d8c997e
Merge pull request #109058 from oliviermichaelis/calculate-start-replicas
Fix replica calculation at start of HPA scaling policy period
2022-08-30 10:58:55 -07:00
Davanum Srinivas
a9593d634c
Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-07-26 13:14:05 -04:00
Olivier Michaelis
3c07d3a20c
Fix replica calculation at start of HPA scaling policy period
When calculating the scale-up/scale-down limit, the number of replicas
at the start of the scaling policy period is calculated correctly by
taken into account the number of scaled-up and scaled-down replicas.

Signed-off-by: Olivier Michaelis <38879457+oliviermichaelis@users.noreply.github.com>
2022-03-27 12:34:32 +02:00
Wojciech Tyczyński
551790729f Remove selflink references in different testing-related files 2022-01-14 12:58:05 +01:00
Joseph Burnett
711f96e05e Watch HPA v2 instead of v1. 2021-11-16 11:13:21 +01:00
wangyysde
d2abddd909 rename v2beta2 to v2
Signed-off-by: wangyysde <net_use@bzhy.com>

Generation swagger.json.

Use v2 path for hpa_cpu_field.

run update-codegen.sh

Signed-off-by: wangyysde <net_use@bzhy.com>
2021-11-09 10:34:54 +08:00
Mike Dame
7780024916 Wire contexts to Autoscaling controllers 2021-10-12 14:34:05 -04:00
Mikkel Oscar Lyderik Larsen
fef092b417
hpa: Don't scale down if at least one metric was invalid
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2021-03-03 07:53:01 +01:00
Joseph Burnett
16133c2b77 Up and down scale stabilize with envelope.
The HPA controller keeps a flat history of recommendations for
stabilization. However when both up and down scale stabilization are
configured, the interpretation of the history changes depending on the
direction of movement. What we want is to keep the stabilized
recommendation within the envelope of the minimum and maximum over
configured stabilization windows. We should only move when the
envelope forces a move.
2020-12-21 14:36:13 +01:00
Ben Hu
4e62298c1b Fix static checks for pkg/controller/podautoscaler 2020-10-23 18:53:07 +00:00
Kubernetes Prow Robot
ec453ffb1a
Merge pull request #90691 from arjunrn/container-resource-hpa
Add container based scaling to HPA
2020-10-23 05:51:51 -07:00
weiwei
b19a115f42 If we set SelectPolicy MinPolicySelect on scaleUp behavior or scaleDown behavior,Horizontal Pod Autoscaler doesn`t automatically scale the number of pods correctly
Signed-off-by: weiwei <weiwei@tenxcloud.com>
2020-10-22 18:00:49 +08:00
Arjun Naik
0fec7b0f7e Added functionality and API for pod autoscaling based on container resources
Signed-off-by: Arjun Naik <anaik@redhat.com>
2020-10-21 21:10:05 +02:00
Alexander Zimmermann
a1c837022c
Fixed Golint errors in pkg/controller/podautoscaler 2020-02-06 17:16:38 +01:00
Arjun Naik
8ab226263a Adds tests
Signed-off-by: Arjun Naik <arjun@arjunnaik.in>
2019-12-10 18:09:20 +01:00
yuxiaobo
81e9f21f83 Correct spelling mistakes
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-11-06 20:25:19 +08:00
Joseph Burnett
a5354d04bb Test more replicas than spec.
During a Deployment update there may be more Pods in the scale target
ref status than in the spec. This test verifies that we do not scale
to the status value. Instead we should stay at the spec value.

Fails before #79035 and passes after.
2019-08-06 14:46:34 +02:00
Rinat Shigapov
d55f037b7d HPA scale-to-zero for custom object/external metrics
Add support for scaling to zero pods

minReplicas is allowed to be zero

condition is set once

Based on https://github.com/kubernetes/kubernetes/pull/61423

set original valid condition

add scale to/from zero and invalid metric tests

Scaling up from zero pods ignores tolerance

validate metrics when minReplicas is 0

Document HPA behaviour when minReplicas is 0

Documented minReplicas field in autoscaling APIs
2019-07-16 08:46:21 -05:00
Sukeesh
44c3f0105f fix incorrect hpa status 2019-07-08 17:27:38 +09:00
GuyTempleton
ee4dbbcbff
Add tests for handling scaling on unavailable metrics
Add three tests for handling invalid metrics when scaling on
multiple metrics - one for scaling up successfully (new behaviour)
and two for ensuring we don't scale down (existing behaviour).
2019-05-29 23:11:32 +01:00
Joel Smith
f50696adda Fix potential test flakes in HPA tests TestEventNotCreated and TestAvoidUncessaryUpdates
Also, re-work the code so that the lock is never held while writing to the chan
2019-04-17 08:10:33 -06:00
Jordan Liggitt
d1e865ee34 Update client callers to use explicit versions 2019-02-26 08:36:30 -05:00
Arjun Naik
c99d505001 Added functionality to use target average value for object metrics
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
2019-01-23 21:00:05 +01:00
Krzysztof Jastrzebski
c6ebd126a7 Add request processing HPA into the queue after processing is finished.
This fixes a bug with skipping request inserted by resync because previous one hasn't processed yet.
2019-01-04 11:59:57 +01:00
Jordan Liggitt
fd9e9b01b1 Remove uses of extensions/v1beta1 clients 2018-12-19 11:18:53 -05:00
Joachim Bartosik
7d7c48a647 HPA stabilizes initial recommendation
HPA will treat initial size of autoscalee to avoid hastily overriding
recomendations made by HPA (if HPA set size and then was restarted) or by user
(initial size should be treated as human-generated recommendation).
2018-09-19 14:54:55 +02:00
Krzysztof Jastrzebski
985ba931b1 Use informer cache instead of active pod gets in HPA controller. 2018-09-05 11:31:27 +02:00
Krzysztof Jastrzebski
958cba1c82 Replace scale down forbidden window
Replacement is scale down stabilization window. HPA will scale down only
    to max of recommendations it made during that window. More details in

    https://docs.google.com/document/d/1IdG3sqgCEaRV3urPLA29IDudCufD89RYCohfBPNeWIM
2018-08-31 20:24:38 +02:00
Kubernetes Submit Queue
2548fb08cd
Merge pull request #68068 from krzysztof-jastrzebski/hpas2
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md.

Change CPU sample sanitization in HPA.

**What this PR does / why we need it**:
Change CPU sample sanitization in HPA.
    Ignore samples if:
    - Pod is beeing initalized - 5 minutes from start defined by flag
        - pod is unready
        - pod is ready but full window of metric hasn't been colected since
        transition
    - Pod is initialized - 5 minutes from start defined by flag:
        - Pod has never been ready after initial readiness period.

**Release notes:**
```release-note
Improve CPU sample sanitization in HPA by taking metric's freshness into account.
```
2018-08-31 10:17:44 -07:00
Krzysztof Jastrzebski
5357bf9eac Change CPU sample sanitization in HPA.
Ignore samples if:
- Pod is beeing initalized - 5 minutes from start defined by flag
    - pod is unready
    - pod is ready but full window of metric hasn't been colected since
    transition
- Pod is initialized - 5 minutes from start defined by flag:
    - Pod has never been ready after initial readiness period.
2018-08-30 23:13:14 +02:00
Kubernetes Submit Queue
42c6f1fb28
Merge pull request #67067 from moonek/master
Automatic merge from submit-queue (batch tested with PRs 67067, 67947). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Do not count soft-deleted pods for scaling purposes in HPA controller

**What this PR does / why we need it**:
The metrics of "soft-deleted" pods in general to be deleted should probably not matter for scaling purposes, since they'll be gone "soon", whether they're nodelost or just normally delete.

As long as soft-deleted pods still exist, they prevent normal scale up.


**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes https://github.com/kubernetes/kubernetes/issues/62845

**Special notes for your reviewer**:

**Release note**:

```release-note
Stop counting soft-deleted pods for scaling purposes in HPA controller to avoid soft-deleted pods incorrectly affecting scale up replica count calculation.
```
2018-08-28 15:08:01 -07:00
moonek
3fedbe48e3 Do not count soft-deleted pods for scaling purposes in HPA controller 2018-08-28 16:27:47 +00:00
Mike Dame
c7102ee5dc Implement autoscaling/v2beta2 features in HPA controller 2018-08-27 11:07:52 -04:00
Joachim Bartosik
4fd6a1684d Make HPA more configurable
Duration of initialization taint on CPU and window of initial readiness
setting controlled by flags.

Adding API violation exceptions following example of e50340ee23
2018-08-24 13:13:02 +02:00
Joachim Bartosik
7d6676eab1 Improve HPA sample sanitization
After my previous changes HPA wasn't behaving correctly in the following
situation:

- Pods use a lot of CPU during initilization, become ready right after they initialize,
- Scale up triggers,
- When new pods become ready HPA counts their usage (even though it's not related to any work that needs doing),
- Another scale up, even though existing pods can handle work, no problem.
2018-08-21 16:22:06 +02:00
Joachim Bartosik
7681c284f5 Remove UpscaleForbiddenWindow
Instead discard metric values for pods that are unready and have never
been ready (they may report misleading values, the original reason for
introducing scale up forbidden window).

Use per pod metric when pod is:
- Ready, or
- Not ready but creation timestamp and last readiness change are more
  than 10s apart.

In the latter case we asume the pod was ready but later became unready.
We want to use metrics for such pods because sometimes such pods are
unready because they were getting too much load.
2018-08-01 17:47:23 +02:00
Joachim Bartosik
086ed3c659 Rename desiredReplicas to expectedDesiredReplicas
Naming fields specifying values expected by test as expected.* is a nice
convention to have, lets follow it.
2018-08-01 17:43:01 +02:00
Dr. Stefan Schimanski
d79cf25497 Update external k8s.io/metrics imports 2018-07-02 10:44:18 +02:00
David Eads
c5445d3c56 simplify api registration 2018-05-08 18:33:50 -04:00
David Eads
9a48066749 update restmapping to indicate fully qualified resource 2018-05-01 16:34:49 -04:00
David Eads
ef0d1ab819 remove incorrect static restmapper 2018-05-01 07:51:17 -04:00
Kubernetes Submit Queue
3d4cd0ace3
Merge pull request #61362 from bskiba/test-em-missing
Automatic merge from submit-queue (batch tested with PRs 60373, 61098, 61352, 61359, 61362). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add HPA test for FailedGetExternalMetric

**What this PR does / why we need it**:
Add a HPA test for missing external metrics.

**Release note**:

```
NONE
```
2018-03-21 22:39:22 -07:00
Beata Skiba
dd24087aa3 Add test for FailedGetExternalMetric 2018-03-19 15:22:36 +01:00
mattjmcnaughton
7e3bce7b3e GetObjectMetricReplicas ignores unready pods
Previously, when `GetObjectMetricReplicas` calculated the desired
replica count, it multiplied the usage ratio by the current number of replicas.
This method caused over-scaling when there were pods that were not ready
for a long period of time. For example, if there were pods A, B, and C,
and only pod A was ready, and the usage ratio was 500%, we would
previously specify 15 pods as the desired replicas (even though really
only one pod was handling the load).

After this change, we now multiple the usage
ratio by the number of ready pods for `GetObjectMetricReplicas`.
In the example above, we'd only desire 5 replica pods.

This change gives `GetObjectMetricReplicas` the same behavior as the
other replica calculator methods. Only `GetExternalMetricReplicas` and
`GetExternalPerPodMetricRepliacs` still allow unready pods to impact the
number of desired replicas. I will fix this issue in the following
commit.
2018-03-07 08:13:01 -05:00
Beata Skiba
e5f8bfa023 Do not count failed pods as unready in HPA controller
Currently, when performing a scale up, any failed pods (which can be present for example in case of evictions performed by kubelet) will be treated as unready. Unready pods are treated as if they had 0% utilization which will slow down or even block scale up.

After this change, failed pods are ignored in all calculations. This way they do not influence neither scale up nor scale down replica calculations.
2018-03-01 16:21:02 +01:00
Aleksandra Malinowska
e58411c600 Implement external metrics in HPA 2018-02-27 14:10:29 +01:00
Maciej Pytel
66f4f9080d Add external metrics client to HPA rest client 2018-02-27 14:10:29 +01:00
Cao Shufeng
4e7398b67b remove duplicated import 2018-01-17 09:34:59 +08:00