-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathdeploy_ci.sh
executable file
·106 lines (87 loc) · 3.15 KB
/
deploy_ci.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
#!/bin/bash
set -e
# This script deploys AIS in an existing k8s cluster from within another node in the cluster
# Gitlab Kubernetes runners have access to kubectl but not minikube cmd line
# Each pod deployed will have its own clusterIP service to communicate without relying on host network
source ../utils.sh
check_variable_set() {
local var_name="$1"
local var_value="${!var_name}"
if [[ -z "$var_value" ]]; then
echo "Error: Required variable '$var_name' is not set."
exit 1
fi
}
# List of required variables
required_vars=("AISNODE_IMAGE" "NUM_TARGET" "NUM_PROXY")
for var in "${required_vars[@]}"; do
check_variable_set "$var"
done
is_number ${NUM_TARGET}
is_number ${NUM_PROXY}
if [[ ${NUM_PROXY} -lt 1 ]]; then
exit_error "${NUM_PROXY} is less than 1"
fi
export TEST_FSPATH_COUNT=${FS_CNT:-4}
PRIMARY_PORT=8080
export AIS_BACKEND_PROVIDERS=$PROVIDERS
INSTANCE=0
if [[ -n $HTTPS ]]; then
source utils/create_certs.sh
export SCHEME="https://"
export AIS_USE_HTTPS=true
export AIS_SKIP_VERIFY_CRT=true
export AIS_SERVER_CRT="/var/certs/tls.crt"
export AIS_SERVER_KEY="/var/certs/tls.key"
export PROTOCOL="HTTPS"
else
export SCHEME="http://"
export AIS_USE_HTTPS=false
export AIS_SKIP_VERIFY_CRT=false
export AIS_SERVER_CRT=""
export AIS_SERVER_KEY=""
export PROTOCOL="HTTP"
fi
export AIS_LOG_DIR="/tmp/ais/log"
export AIS_PRIMARY_HOST="ais-proxy-0.default.svc.cluster.local"
export AIS_PRIMARY_URL="${SCHEME}${AIS_PRIMARY_HOST}:${PRIMARY_PORT}"
if [[ ",$PROVIDERS," == *",gcp,"* ]]; then
echo "Creating GCP credentials secret"
kubectl delete secret gcp-creds || true
kubectl create secret generic gcp-creds --from-file=creds.json=$GOOGLE_APPLICATION_CREDENTIALS
fi
# Necessary in case another run with different spec is aborted
echo "Cleaning up any previous deployment"
source utils/cleanup_k8s_ci.sh
echo "Starting AIS deployment..."
echo "Starting primary proxy deployment..."
for i in $(seq 0 $((NUM_PROXY-1))); do
export POD_NAME="ais-proxy-${i}"
export PORT=$((PRIMARY_PORT+i))
export INSTANCE=${INSTANCE}
# Use a clusterIP service for each pod for communication without host network
export HOSTNAME_LIST="$POD_NAME.default.svc.cluster.local"
envsubst < kube_templates/ci_proxy.yml | kubectl delete -f - || true
envsubst < kube_templates/ci_proxy.yml | kubectl apply -f -
INSTANCE=$((INSTANCE+1))
done
echo "Waiting for the primary proxy to be ready..."
kubectl wait --for="condition=ready" --timeout=2m pod ais-proxy-0
echo "Starting target deployment..."
INSTANCE=0
for i in $(seq 0 $((NUM_TARGET-1))); do
export POD_NAME="ais-target-${i}"
export PORT=$((9090+i))
export PORT_INTRA_CONTROL=$((9080+i))
export PORT_INTRA_DATA=$((10080+i))
export TARGET_POS_NUM=$i
export INSTANCE=${INSTANCE}
export HOSTNAME_LIST="$POD_NAME.default.svc.cluster.local"
envsubst < kube_templates/ci_target.yml | kubectl delete -f - || true
envsubst < kube_templates/ci_target.yml | kubectl create -f -
INSTANCE=$((INSTANCE+1))
done
echo "Waiting for the targets to be ready..."
kubectl wait --for="condition=ready" --timeout=2m pods -l type=ais-target
echo "List of running pods"
kubectl get pods -o wide