Skip to content

Commit

Permalink
Update horizontal-pod-autoscaler.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
devopstrainingbanglore authored Jan 14, 2020
1 parent 050344d commit bacee84
Showing 1 changed file with 33 additions and 41 deletions.
74 changes: 33 additions & 41 deletions horizontal-pod-autoscaler.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: hpadeploymentautoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: hpadeployment
minReplicas: 2
maxReplicas: 5
metrics:
- resource:
name: cpu
targetAverageUtilization: 100
type: Resource
---
apiVersion: v1
kind: Service
metadata:
name: hpaclusterservice
labels:
name: hpaservice
spec:
ports:
- port: 80
targetPort: 80
selector:
name: hpapod
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -54,16 +23,39 @@ spec:
containerPort: 80
resources:
requests:
cpu: "200m"
cpu: "100m"
memory: "64Mi"
limits:
limits:
cpu: "100m"
memory: "256Mi"
# ==== Execute below commonds to increase load====

#Now, we will see how the autoscaler reacts to increased load. We will start a container, and send an infinite loop of queries to the php-apache service (please run it in a different terminal):
# Create A Temp Pod in interactive mod to access app using service name
# kubectl run -i --tty load-generator --rm --image=busybox /bin/sh
# Execute below commond in Temp Pod
# while true; do wget -q -O- http://hpaclusterservice; done
---
apiVersion: v1
kind: Service
metadata:
name: hpaclusterservice
labels:
name: hpaservice
spec:
ports:
- port: 80
targetPort: 80
selector:
name: hpapod
type: ClusterIP
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: hpadeploymentautoscaler
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: hpadeployment
minReplicas: 2
maxReplicas: 5
metrics:
- resource:
name: cpu
targetAverageUtilization: 50
type: Resource

0 comments on commit bacee84

Please sign in to comment.