Skip to content

Commit 8ead140

Browse files
authored
Add support for horizontal pod autoscaling (#1676)
1 parent 6820981 commit 8ead140

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

config/crd/bases/awx.ansible.com_awxs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,10 +1574,18 @@ spec:
15741574
description: Number of web instance replicas
15751575
type: integer
15761576
format: int32
1577+
web_manage_replicas:
1578+
description: Enables operator control of replicas count for the web deployment when set to 'true'
1579+
type: boolean
1580+
default: true
15771581
task_replicas:
15781582
description: Number of task instance replicas
15791583
type: integer
15801584
format: int32
1585+
task_manage_replicas:
1586+
description: Enables operator control of replicas count for the task deployment when set to 'true'
1587+
type: boolean
1588+
default: true
15811589
web_liveness_initial_delay:
15821590
description: Initial delay before starting liveness checks on web pod
15831591
type: integer
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Horizontal Pod Autoscaler (HPA)
2+
3+
Horizontal Pod Autoscaler allows Kubernetes to scale the number of replicas of
4+
deployments in response to configured metrics.
5+
6+
This feature conflicts with the operators ability to manage the number of static
7+
replicas to create for each deployment.
8+
9+
The use of the settings below will tell the operator to not manage the replicas
10+
field on the identified deployments even if a replicas count has been set for those
11+
properties in the operator resource.
12+
13+
| Name | Description | Default |
14+
| -----------------------| ----------------------------------------- | ------- |
15+
| web_manage_replicas | Indicates operator should control the | true |
16+
| | replicas count for the web deployment. | |
17+
| | | |
18+
| task_manage_replicas | Indicates operator should control the | true |
19+
| | replicas count for the task deployment. | |
20+
21+
#### Recommended Settings for HPA
22+
23+
Please see the Kubernetes documentation on how to configure the horizontal pod
24+
autoscaler.
25+
26+
The values for optimal HPA are cluster and need specific so general guidelines
27+
are not available at this time.
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
#### Scaling the Web and Task Pods independently
1+
#### Scaling the Web and Task Pods independently
22

33
You can scale replicas up or down for each deployment by using the `web_replicas` or `task_replicas` respectively. You can scale all pods across both deployments by using `replicas` as well. The logic behind these CRD keys acts as such:
44

5-
- If you specify the `replicas` field, the key passed will scale both the `web` and `task` replicas to the same number.
5+
- If you specify the `replicas` field, the key passed will scale both the `web` and `task` replicas to the same number.
66
- If `web_replicas` or `task_replicas` is ever passed, it will override the existing `replicas` field on the specific deployment with the new key value.
77

8-
These new replicas can be constrained in a similar manner to previous single deployments by appending the particular deployment name in front of the constraint used. More about those new constraints can be found in the [Assigning AWX pods to specific nodes](./assigning-awx-pods-to-specific-nodes.md) page.
8+
These new replicas can be constrained in a similar manner to previous single deployments by appending the particular deployment name in front of the constraint used. More about those new constraints can be found in the [Assigning AWX pods to specific nodes](./assigning-awx-pods-to-specific-nodes.md) page.
9+
10+
##### Horizontal Pod Autoscaling
11+
12+
The operator is capable of working with Kubernete's HPA capabilities. See [Horizontal Pod Autoscaler](./horizontal-pod-autoscaler.md)
13+
documentation for more information.

roles/installer/templates/deployments/task.yaml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ metadata:
88
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
99
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=4) | trim }}
1010
spec:
11-
{% if task_replicas != '' %}
11+
{% if task_replicas != '' and task_manage_replicas is true %}
1212
replicas: {{ task_replicas }}
13-
{% elif replicas != '' %}
13+
{% elif replicas != '' and task_manage_replicas is true %}
1414
replicas: {{ replicas }}
1515
{% endif %}
1616
selector:

roles/installer/templates/deployments/web.yaml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ metadata:
99
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
1010
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=4) | trim }}
1111
spec:
12-
{% if web_replicas != '' %}
12+
{% if web_replicas != '' and web_manage_replicas is true %}
1313
replicas: {{ web_replicas }}
14-
{% elif replicas != '' %}
14+
{% elif replicas != '' and web_manage_replicas is true %}
1515
replicas: {{ replicas }}
1616
{% endif %}
1717
selector:

0 commit comments

Comments
 (0)