autoscaling

This commit is contained in:
Steve Waterworth
2019-05-22 15:54:05 +01:00
parent 51f0c93e6c
commit e5c10b597f
12 changed files with 57 additions and 164 deletions

14
K8s/autoscaling/autoscale.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
NS="robot-shop"
DEPLOYMENTS="cart catalogue dispatch payment ratings shipping user web"
for DEP in $DEPLOYMENTS
do
kubectl -n $NS autoscale deployment $DEP --max 2 --min 1 --cpu-percent 50
done
echo "Waiting 5 seconds for changes to apply..."
sleep 5
kubectl -n $NS get hpa

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: cart
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: cart
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: catalogue
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: catalogue
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: dispatch
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: dispatch
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: payment
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: payment
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: ratings
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ratings
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: shipping
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: shipping
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: user
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: user
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -1,18 +0,0 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: web
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web
minReplicas: 1
maxReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -18,11 +18,11 @@ spec:
- name: load
env:
- name: HOST
value: "http://web:8080"
value: "http://web:8080/"
- name: NUM_CLIENTS
value: "15"
- name: SILENT
value: "0"
value: "1"
- name: ERROR
value: "1"
image: robotshop/rs-load:latest