forked from MithunTechnologiesDevOps/Kubernates-Manifests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create horizontal-pod-autoscaler.yml
- Loading branch information
1 parent
5b92dc6
commit 050344d
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |