Skip to content

Commit e365b98

Browse files
committed
Add keda example
1 parent ad90613 commit e365b98

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Enable Keda scale to 0 in off hours
2+
3+
This example is based on the official Keda [example](https://keda.sh/docs/2.18/scalers/cron/#scale-to-0-during-off-hours).
4+
5+
## 1. Deploy the Ingress Controller
6+
7+
1. Follow the [installation](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/)
8+
instructions to deploy the Ingress Controller.
9+
10+
## 2. Deploy Keda
11+
12+
1. Follow the [installation](https://keda.sh/docs/2.18/deploy/) instructions to suit your deployment preference.
13+
14+
## 3. Apply the Keda ScaledObject
15+
16+
Adjust the setting to suit your requirements. See the [ScaledObject](https://keda.sh/docs/2.18/reference/scaledobject-spec/) reference for more details
17+
18+
1. Apply `scaled-object.yaml`
19+
20+
```console
21+
kubectl apply -f scaled-object.yaml
22+
```
23+
24+
## 4. Configure deployment replicas
25+
26+
1. Remove the `spec.replicas` from your deployment to allow Keda to autoscale your pods.
27+
28+
2. Once the end time has expired, 5 minutes from then the NGINX Ingress Controller pods should scale to 0.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: keda.sh/v1alpha1
2+
kind: ScaledObject
3+
metadata:
4+
name: cron-scaledobject
5+
namespace: nginx-ingress
6+
spec:
7+
scaleTargetRef:
8+
name: nginx-ingress
9+
minReplicaCount: 0
10+
maxReplicaCount: 4
11+
cooldownPeriod: 300
12+
triggers:
13+
- type: cron
14+
metadata:
15+
timezone: Europe/London
16+
start: 0 09 * * *
17+
end: 30 17 * * *
18+
desiredReplicas: "1"
19+
- type: cpu
20+
metricType: Utilization
21+
metadata:
22+
value: "80"

0 commit comments

Comments
 (0)