Skip to content

Commit 78d1169

Browse files
committed
Documentation updates
1 parent 9045dd9 commit 78d1169

File tree

7 files changed

+100
-87
lines changed

7 files changed

+100
-87
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ or HTTP request.
4444
- Supports Kubernetes metrics that the Horizontal Pod Autoscaler uses, can be configured using a similar syntax and
4545
used in custom scaling decisions.
4646
- Supports [Argo Rollouts](https://argoproj.github.io/argo-rollouts/).
47+
- Supports targeting any custom resource that implements the scale subresource.
4748

4849
## Why would I use it?
4950

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ or HTTP request.
3030
- Supports Kubernetes metrics that the Horizontal Pod Autoscaler uses, can be configured using a similar syntax and
3131
used in custom scaling decisions.
3232
- Supports [Argo Rollouts](https://argoproj.github.io/argo-rollouts/).
33+
- Supports targeting any custom resource that implements the scale subresource.
3334

3435
## Why would I use it?
3536

docs/reference/docker-images.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
The Custom Pod Autoscaler is bundled with the following Docker base images:
44

5-
- `custompodautoscaler/python` tracks latest stable Python 3.x release (alpine based).
6-
- `custompodautoscaler/python-3-13` tracks latest stable Python 3.13.x release (alpine based).
7-
- `custompodautoscaler/python-3-12` tracks latest stable Python 3.12.x release (debian 12 bookworm based).
5+
- `custompodautoscaler/python` tracks latest stable Python 3.x release (debian based).
6+
- `custompodautoscaler/python-3-13` tracks latest stable Python 3.13.x release (debian based).
7+
- `custompodautoscaler/python-3-12` tracks latest stable Python 3.12.x release (debian based).
88
- `custompodautoscaler/alpine` tracks latest stable Alpine 3.x release.
99

1010
## Deprecated images

docs/reference/scaling-targets.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ scale subresource API. For example this means support for:
1313
* Argo Rollouts
1414
* Other third party resources.
1515

16+
> To see how to target custom resources [see the Custom Resources page](../user-guide/custom-resources.md).
17+
1618
## Scale target reference
1719

1820
To tell a Custom Pod Autoscaler which resource to target, provide a `scaleTargetRef` - a description of the resource to
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Custom Resources
2+
3+
The Custom Pod Autoscaler supports targeting custom resources; however this requires some additional configuration
4+
to make sure the autoscaler has the required permissions to be able to manage the targeted resources.
5+
6+
By default the [Custom Pod Autoscaler
7+
Operator](https://github.com/jthomperoo/custom-pod-autoscaler-operator) will provision a role for your autoscaler
8+
which allows managing the built-in Kubernetes resources (deployments, replicasets, statefulsets,
9+
replicationcontrollers), but if you are targeting a custom resource you need to provide your own role with the
10+
correct permissions.
11+
12+
You need to tell the operator not to provision a role for you, and provide your own with the permissions needed,
13+
for example to target Loadstash:
14+
15+
```yaml
16+
apiVersion: rbac.authorization.k8s.io/v1
17+
kind: Role
18+
metadata:
19+
name: python-custom-autoscaler
20+
rules:
21+
- apiGroups:
22+
- logstash.k8s.elastic.co
23+
resources:
24+
- logstashes
25+
- logstashes/scale
26+
verbs:
27+
- '*'
28+
---
29+
apiVersion: v1
30+
kind: ServiceAccount
31+
metadata:
32+
name: python-custom-autoscaler
33+
---
34+
kind: RoleBinding
35+
apiVersion: rbac.authorization.k8s.io/v1
36+
metadata:
37+
name: python-custom-autoscaler
38+
subjects:
39+
- kind: ServiceAccount
40+
name: python-custom-autoscaler
41+
roleRef:
42+
kind: Role
43+
name: python-custom-autoscaler
44+
apiGroup: rbac.authorization.k8s.io
45+
---
46+
apiVersion: custompodautoscaler.com/v1
47+
kind: CustomPodAutoscaler
48+
metadata:
49+
name: python-custom-autoscaler
50+
spec:
51+
template:
52+
spec:
53+
serviceAccountName: python-custom-autoscaler
54+
containers:
55+
- name: python-custom-autoscaler
56+
image: python-custom-autoscaler:latest
57+
imagePullPolicy: IfNotPresent
58+
scaleTargetRef:
59+
apiVersion: logstash.k8s.elastic.co/v1alpha1
60+
kind: Logstash
61+
name: quickstart
62+
provisionRole: false
63+
provisionRoleBinding: false
64+
provisionServiceAccount: false
65+
config:
66+
- name: interval
67+
value: "10000"
68+
```
69+
70+
This takes over provisioning of the role, the role binding, and the service account from the operator.
71+
72+
For any custom resource the CPO can support scaling it if the resource implements the scale subresource, and if so
73+
the permissions needed are generally:
74+
75+
```yaml
76+
- apiGroups:
77+
- my.api.group
78+
resources:
79+
- mycustomresource
80+
- mycustomresource/scale
81+
verbs:
82+
- '*'
83+
```
84+
85+
There is a special case for [Argo Rollouts](https://argoproj.github.io/rollouts/), which can simply provide the
86+
`roleRequiresArgoRollouts` field. [See more information
87+
here](https://github.com/jthomperoo/custom-pod-autoscaler-operator/blob/v1.4.2/USAGE.md#automatically-provisioning-a-role-that-supports-argo-rollouts).
88+
89+
[See how to skip automatic role/any other resource provision
90+
here](https://github.com/jthomperoo/custom-pod-autoscaler-operator/blob/v1.4.2/USAGE.md#using-custom-resources).

docs/user-guide/troubleshooting.md

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -13,88 +13,6 @@ E0214 11:30:09.556332 1 main.go:266] Error while autoscaling: failed to ge
1313
And see that your autoscaler is not scaling the target resource if you are targeting a custom resource.
1414

1515
This is because your autoscaler does not have the correct permissions to manage the resource you are
16-
targeting. By default the [Custom Pod Autoscaler
17-
Operator](https://github.com/jthomperoo/custom-pod-autoscaler-operator) will provision a role for your autoscaler
18-
which allows managing the built-in Kubernetes resources (deployments, replicasets, statefulsets,
19-
replicationcontrollers), but if you are targeting a custom resource you need to provide your own role with the
20-
correct permissions.
16+
targeting.
2117

22-
You need to tell the operator not to provision a role for you, and provide your own with the permissions needed,
23-
for example to target Loadstash:
24-
25-
```yaml
26-
apiVersion: rbac.authorization.k8s.io/v1
27-
kind: Role
28-
metadata:
29-
name: python-custom-autoscaler
30-
rules:
31-
- apiGroups:
32-
- logstash.k8s.elastic.co
33-
resources:
34-
- logstashes
35-
- logstashes/scale
36-
verbs:
37-
- '*'
38-
---
39-
apiVersion: v1
40-
kind: ServiceAccount
41-
metadata:
42-
name: python-custom-autoscaler
43-
---
44-
kind: RoleBinding
45-
apiVersion: rbac.authorization.k8s.io/v1
46-
metadata:
47-
name: python-custom-autoscaler
48-
subjects:
49-
- kind: ServiceAccount
50-
name: python-custom-autoscaler
51-
roleRef:
52-
kind: Role
53-
name: python-custom-autoscaler
54-
apiGroup: rbac.authorization.k8s.io
55-
---
56-
apiVersion: custompodautoscaler.com/v1
57-
kind: CustomPodAutoscaler
58-
metadata:
59-
name: python-custom-autoscaler
60-
spec:
61-
template:
62-
spec:
63-
serviceAccountName: python-custom-autoscaler
64-
containers:
65-
- name: python-custom-autoscaler
66-
image: python-custom-autoscaler:latest
67-
imagePullPolicy: IfNotPresent
68-
scaleTargetRef:
69-
apiVersion: logstash.k8s.elastic.co/v1alpha1
70-
kind: Logstash
71-
name: quickstart
72-
provisionRole: false
73-
provisionRoleBinding: false
74-
provisionServiceAccount: false
75-
config:
76-
- name: interval
77-
value: "10000"
78-
```
79-
80-
This takes over provisioning of the role, the role binding, and the service account from the operator.
81-
82-
For any custom resource the CPO can support scaling it if the resource implements the scale subresource, and if so
83-
the permissions needed are generally:
84-
85-
```yaml
86-
- apiGroups:
87-
- my.api.group
88-
resources:
89-
- mycustomresource
90-
- mycustomresource/scale
91-
verbs:
92-
- '*'
93-
```
94-
95-
There is a special case for [Argo Rollouts](https://argoproj.github.io/rollouts/), which can simply provide the
96-
`roleRequiresArgoRollouts` field. [See more information
97-
here](https://github.com/jthomperoo/custom-pod-autoscaler-operator/blob/v1.4.2/USAGE.md#automatically-provisioning-a-role-that-supports-argo-rollouts).
98-
99-
[See how to skip automatic role/any other resource provision
100-
here](https://github.com/jthomperoo/custom-pod-autoscaler-operator/blob/v1.4.2/USAGE.md#using-custom-resources).
18+
See [the Custom Resources page for details on how to resolve this](./custom-resources.md).

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ nav:
2929
- 'Zero Scaling': 'user-guide/scaling-to-and-from-zero.md'
3030
- 'Pausing and Un-pausing scaling': 'user-guide/pausing-and-unpausing-scaling.md'
3131
- 'Kubernetes Metrics': 'user-guide/kubernetes-metrics.md'
32+
- 'Custom Resources': 'user-guide/custom-resources.md'
3233
- 'Migrating v1 to v2': 'user-guide/migrating-v1-to-v2.md'
3334
- 'Troubleshooting': 'user-guide/troubleshooting.md'
3435
- Reference:

0 commit comments

Comments
 (0)