-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathhorizontal-pod-autoscaler.yaml
More file actions
75 lines (65 loc) · 2.34 KB
/
horizontal-pod-autoscaler.yaml
File metadata and controls
75 lines (65 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# Author: Hari Sekhon
# Date: [% DATE # 2019-11-27 12:19:45 +0000 (Wed, 27 Nov 2019) %]
#
# vim:ts=2:sts=2:sw=2:et
# lint: k8s
#
# https://github.com/HariSekhon/Kubernetes-configs
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn
# and optionally send me feedback to help improve or steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
# ============================================================================ #
# H o r i z o n t a l P o d A u t o s c a l e r
# ============================================================================ #
# https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/
# https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v1/
# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/horizontal-pod-autoscaler-v2/
# Metrics Server needs to be deployed for HPA to query to make scaling decisions
#
# Metrics Server is automatically available on GKE but may need to be added on EKS
# XXX: HPA may break with lack of metrics - <unknown>/70% - if containers are added to pod without resource requests section
---
apiVersion: autoscaling/v1
#apiVersion: autoscaling/v2beta2 # k8s 1.6+ - scale using the largest of multiple metrics
kind: HorizontalPodAutoscaler
metadata:
name: APP-hpa
namespace: NAMESPACE
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: APP-deployment
minReplicas: 3
maxReplicas: 5
targetCPUUtilizationPercentage: 70
# multiple metrics using autoscaling/v2beta2 - remove targetCPUUtilizationPercentage if using this
# metrics:
# - type: Resource
# resource:
# name: cpu
# target:
# type: Utilization
# averageUtilization: 70
# - type: Resource
# resource:
# name: memory
# #targetAverageValue: 250M
# target:
# type: AverageValue
# averageValue: 250Mi
# Kubernetes 1.20+ - container level resource metrics - check the important container in the pod
# type: ContainerResource
# containerResource:
# name: cpu
# container: application
# target:
# type: Utilization
# averageUtilization: 60