Skip to content

Commit 7c43af1

Browse files
committed
Update headroom-controller examples
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 445e83e commit 7c43af1

15 files changed

+411
-322
lines changed

chart/headroom-controller/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: headroom-controller
33
description: A Helm chart for headroom-controller - Kubernetes resource reservation controller
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: "0.1.0"
77
keywords:
88
- kubernetes

chart/headroom-controller/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,71 @@ EOF
125125

126126
`kubectl scale headroom example --replicas=2`
127127

128+
## Advanced example - scale a headroom down from a Cron Job
129+
130+
Imagine you wanted to scale down the headroom resource overnight.
131+
132+
Here's an example of how Kubernetes-native resources can be used.
133+
134+
```yaml
135+
kind: CronJob
136+
apiVersion: batch/v1
137+
metadata:
138+
name: scale-headroom
139+
namespace: default
140+
spec:
141+
schedule: "0 0 * * * *"
142+
successfulJobsHistoryLimit: 5 # Keep 5 successful jobs
143+
failedJobsHistoryLimit: 1 # Keep 1 failed job
144+
jobTemplate:
145+
spec:
146+
template:
147+
spec:
148+
serviceAccountName: headroom-scaler
149+
restartPolicy: OnFailure
150+
containers:
151+
- name: kubectl
152+
image: alpine/k8s:1.33.3 # Or a specific version
153+
command:
154+
- "/bin/sh"
155+
- "-c"
156+
- |
157+
apk add --no-cache kubectl
158+
kubectl scale headroom/example --replicas=0
159+
---
160+
apiVersion: v1
161+
kind: ServiceAccount
162+
metadata:
163+
name: headroom-scaler
164+
namespace: default # Or your target namespace
165+
166+
---
167+
apiVersion: rbac.authorization.k8s.io/v1
168+
kind: ClusterRoleBinding # Or RoleBinding if headroom controller is namespace scoped
169+
metadata:
170+
name: headroom-scaler-rb
171+
namespace: default
172+
subjects:
173+
- kind: ServiceAccount
174+
name: headroom-scaler
175+
namespace: default
176+
roleRef:
177+
kind: ClusterRole # Or Role if headroom controller is namespace scoped
178+
name: headroom-scaler-role
179+
apiGroup: rbac.authorization.k8s.io
180+
181+
---
182+
apiVersion: rbac.authorization.k8s.io/v1
183+
kind: ClusterRole # Or Role if headroom controller is namespace scoped
184+
metadata:
185+
name: headroom-scaler-role
186+
namespace: default
187+
rules:
188+
- apiGroups: ["openfaas.com"]
189+
resources: ["headrooms", "headrooms/scale"]
190+
verbs: ["get", "patch", "update"]
191+
```
192+
128193
## Configuration
129194
130195
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

docs/cron-connector-0.6.13.tgz

0 Bytes
Binary file not shown.

docs/headroom-controller-0.1.1.tgz

14.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)