Skip to content

Commit 21335a2

Browse files
committed
Example of defining scheduled scaling for Prometheus
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
1 parent 7a9a1df commit 21335a2

File tree

6 files changed

+558
-0
lines changed

6 files changed

+558
-0
lines changed

cluster/config-defaults.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,13 @@ prometheus_remote_max_backoff: "10s"
534534
# Comma-separated list of user ids allowed to access Prometheus UI
535535
prometheus_ui_users: ""
536536

537+
# Scheduled scaling events for Prometheus VPA (in the format
538+
# <name>:<pre-start-min>:<cpu>:<memory>, multiple events separated by commas)
539+
prometheus_scheduled_scaling_events: ""
540+
541+
# Enable scheduled scaling for VPA
542+
scheduled_scaling_vpa_enabled: "false"
543+
537544
metrics_service_cpu: "100m"
538545
metrics_service_mem_max: "4Gi"
539546
metrics_server_metric_resolution: "15s"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- if eq .Cluster.ConfigItems.scheduled_scaling_vpa_enabled "true" }}
2+
apiVersion: batch/v1
3+
kind: CronJob
4+
metadata:
5+
name: scheduled-scaling-vpa
6+
namespace: kube-system
7+
labels:
8+
application: kubernetes
9+
component: scheduled-scaling-vpa
10+
spec:
11+
schedule: "*/5 * * * *"
12+
concurrencyPolicy: Forbid
13+
startingDeadlineSeconds: 30
14+
successfulJobsHistoryLimit: 1
15+
failedJobsHistoryLimit: 1
16+
jobTemplate:
17+
metadata:
18+
labels:
19+
application: kubernetes
20+
component: scheduled-scaling-vpa
21+
spec:
22+
activeDeadlineSeconds: 30
23+
backoffLimit: 1
24+
template:
25+
metadata:
26+
labels:
27+
application: kubernetes
28+
component: scheduled-scaling-vpa
29+
annotations:
30+
logging/destination: "{{.Cluster.ConfigItems.log_destination_infra}}"
31+
spec:
32+
serviceAccountName: scheduled-scaling-vpa
33+
restartPolicy: Never
34+
containers:
35+
- name: main
36+
image: container-registry-test.zalando.net/cloud-platform/scheduled-scaling-vpa:pr-1-4
37+
{{- end }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{{ if eq .Cluster.ConfigItems.scheduled_scaling_vpa_enabled "true" }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: scheduled-scaling-vpa
6+
namespace: kube-system
7+
labels:
8+
application: kubernetes
9+
component: scheduled-scaling-vpa
10+
---
11+
apiVersion: rbac.authorization.k8s.io/v1
12+
kind: ClusterRole
13+
metadata:
14+
name: scheduled-scaling-vpa
15+
labels:
16+
application: kubernetes
17+
component: scheduled-scaling-vpa
18+
rules:
19+
- apiGroups: ["autoscaling.k8s.io"]
20+
resources: ["verticalpodautoscalers"]
21+
verbs: ["get", "list", "watch", "create", "update", "patch"]
22+
- apiGroups: ["zalando.org"]
23+
resources:
24+
- "verticalpodautoscalers"
25+
- "scalingschedules"
26+
- "clusterscalingschedules"
27+
verbs: ["get", "list", "watch"]
28+
---
29+
apiVersion: rbac.authorization.k8s.io/v1
30+
kind: ClusterRoleBinding
31+
metadata:
32+
name: scheduled-scaling-vpa
33+
labels:
34+
application: kubernetes
35+
component: scheduled-scaling-vpa
36+
roleRef:
37+
apiGroup: rbac.authorization.k8s.io
38+
kind: ClusterRole
39+
name: scheduled-scaling-vpa
40+
subjects:
41+
- kind: ServiceAccount
42+
name: scheduled-scaling-vpa
43+
namespace: kube-system
44+
{{- end }}

0 commit comments

Comments
 (0)