-
Notifications
You must be signed in to change notification settings - Fork 0
/
determine-single-pod-request-rate.sh
executable file
·128 lines (96 loc) · 3.29 KB
/
determine-single-pod-request-rate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
set -euo pipefail
source time_it.sh
floating_ip=a.b.c.d
istio_node=changeme
DELAY=${1}
COUNT=${2}
SERVICES=backend
deploy_istio () {
if kubectl get namespace istio-system; then
echo "Istio already deployed..."
return
fi
echo "Deploying Istio..."
kubectl label node ${istio_node} istio=runshere --overwrite
kubectl create namespace istio-system
kubectl apply -f application/istio/istio-init.yaml
until [ $(kubectl get crds | grep 'istio.io\|certmanager.k8s.io' | wc -l) -eq $(grep 'CustomResourceDefinition' application/istio/istio-init.yml | wc -l) ]; do
echo "Waiting for Istio CRDs to be applied..."
sleep 5
done
kubectl apply -f application/istio/istio.yaml
until [ $(kubectl get pods -n istio-system --no-headers | grep -v 'Running\|Completed' | wc -l) -eq 1 ]; do
echo "Waiting for Istio deploy to be fully completed and running..."
sleep 5
done
kubectl label namespace default istio-injection=enabled --overwrite
kubectl apply -f application/k8s/gateway.yaml
}
remove_istio () {
if ! kubectl get namespace istio-system; then
echo "Istio not deployed..."
return
fi
echo "Removing Istio..."
# Delete in the reverse order that resources were created
kubectl delete -f application/k8s/gateway.yaml
kubectl label namespace default istio-injection=disabled --overwrite
kubectl delete -f application/istio/istio.yaml
# This command tries to delete too much (Certificate Manager) stuff,
# so we must ignore its true exit code
kubectl delete -f istio/install/kubernetes/helm/istio-init/files || true
until [ $(kubectl get crds | grep 'istio.io\|certmanager.k8s.io' | wc -l) -eq 0 ]; do
echo "Waiting for Istio CRDs to be deleted..."
sleep 5
done
kubectl delete namespace istio-system
}
remove_application () {
# Removes "too much" but who cares, it should be gone, anyway...
for service in "${SERVICES}"; do
kubectl delete -R -f application/${service}/k8s || true
done
until [ $(kubectl get pods | grep ${service} | wc -l) -eq 0 ]; do
echo "Waiting for all ${service} Pods to shut down..."
sleep 5
done
}
deploy () {
service_mesh=$1
min_replicas=1
max_replicas=1
echo "Should deploy ${service_mesh} with replicas exactly ${max_replicas}"
if [ "${service_mesh}" == "istio" ]; then
deploy_istio
kubectl apply -f application/k8s/gateway.yaml
else
remove_istio
fi
for service in "${SERVICES}"; do
echo "Deploying service ${service}..."
# TODO Modify Deploment to deploy min_replicas of the service
kubectl apply -f application/${service}/k8s/${service_mesh}
#if [ ${min_replicas} != ${max_replicas} ]; then
sed -e "s/minReplicas: .*/minReplicas: ${min_replicas}/g" \
-e "s/maxReplicas: .*/maxReplicas: ${max_replicas}/g" \
application/${service}/k8s/hpa.yaml | kubectl apply -f -
#fi
done
}
for service_mesh in istio none; do
remove_application
if [ "${service_mesh}" == "istio" ]; then
backend='http://backend.${floating_ip}.xip.io:31380/backend'
else
backend='http://backend.${floating_ip}.xip.io:31000'
fi
deploy ${service_mesh}
count=0
while [ ${count} -le ${COUNT} ]; do
echo $(date +%s | tr '\n' ','; time_it curl -s "${backend}/tokyo.png?top=0&left=0&bottom=30&right=30") >> single-pod-request-rate-${service_mesh}.csv
sleep ${DELAY}
count=$(($count + 1))
echo "${service_mesh}: ${count}/${COUNT}"
done
done