Skip to content

Commit 518d064

Browse files
committed
Add Examples, show how hpa and vpa works
1 parent e125e7a commit 518d064

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

examples/combined-hpa-vpa.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Horizontal and Vertical Pod Autoscaler configuration to test Kubernetes auto-scaling.
2+
# This configuration will adjust the deployment scale based on CPU and memory utilization.
3+
4+
# Horizontal Pod Autoscaler (HPA)
5+
apiVersion: autoscaling/v2
6+
kind: HorizontalPodAutoscaler
7+
metadata:
8+
name: sample-combined-hpa
9+
namespace: default
10+
spec:
11+
scaleTargetRef:
12+
apiVersion: apps/v1
13+
kind: Deployment
14+
name: sample-deployment
15+
minReplicas: 2 # Set minimum replica count
16+
maxReplicas: 10 # Set maximum replica count
17+
metrics:
18+
- type: Resource
19+
resource:
20+
name: cpu
21+
target:
22+
type: Utilization
23+
averageUtilization: 70 # CPU usage target (in %)
24+
25+
---
26+
27+
# Vertical Pod Autoscaler (VPA)
28+
# Automatically adjusts resource requests and limits based on actual usage.
29+
apiVersion: autoscaling.k8s.io/v1
30+
kind: VerticalPodAutoscaler
31+
metadata:
32+
name: sample-combined-vpa
33+
namespace: default
34+
spec:
35+
targetRef:
36+
apiVersion: apps/v1
37+
kind: Deployment
38+
name: sample-deployment
39+
updatePolicy:
40+
updateMode: "Auto" # Enable automatic scaling based on VPA recommendations.

examples/hpa-example.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Horizontal Pod Autoscaler (HPA) example configuration for Kubernetes.
2+
# This HPA scales the sample-deployment based on CPU and memory usage metrics.
3+
4+
apiVersion: autoscaling/v2
5+
kind: HorizontalPodAutoscaler
6+
metadata:
7+
name: sample-hpa
8+
namespace: default
9+
spec:
10+
scaleTargetRef:
11+
# Reference to the deployment we want to scale.
12+
apiVersion: apps/v1
13+
kind: Deployment
14+
name: sample-deployment
15+
minReplicas: 2 # Minimum number of replicas that HPA will maintain.
16+
maxReplicas: 10 # Maximum number of replicas to which HPA can scale up.
17+
metrics:
18+
- type: Resource
19+
resource:
20+
name: cpu
21+
target:
22+
type: Utilization
23+
averageUtilization: 70 # Target 70% CPU usage

examples/vpa-example.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: autoscaling.k8s.io/v1
2+
kind: VerticalPodAutoscaler
3+
metadata:
4+
name: sample-vpa
5+
namespace: default
6+
spec:
7+
targetRef:
8+
apiVersion: apps/v1
9+
kind: Deployment
10+
name: sample-deployment
11+
updatePolicy:
12+
updateMode: "Auto" # Automatic resizing of resources

0 commit comments

Comments
 (0)