Skip to content

Commit

Permalink
Create horizontal-pod-autoscaler.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
devopstrainingbanglore authored Nov 27, 2019
1 parent 5b92dc6 commit 050344d
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions horizontal-pod-autoscaler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
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:
name: hpadeployment
labels:
name: hpadeployment
spec:
replicas: 2
selector:
matchLabels:
name: hpapod
template:
metadata:
labels:
name: hpapod
spec:
containers:
- name: hpacontainer
image: k8s.gcr.io/hpa-example
ports:
- name: http
containerPort: 80
resources:
requests:
cpu: "200m"
memory: "64Mi"
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

0 comments on commit 050344d

Please sign in to comment.