forked from kubeshop/tracetest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·58 lines (45 loc) · 1.91 KB
/
deploy.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
#/bin/bash
set -ex
if [ -z "$NAME" ];then
echo '$NAME is required'
exit 1
fi
if [ -z "$TAG" ];then
echo '$TAG is required'
exit 1
fi
if [ -z "$CONFIG_FILE" ];then
echo '$CONFIG_FILE is required'
exit 1
fi
extraParams=()
if [ -n "$EXPOSE_HOST" ]; then
extraParams=("${extraParams[@]}" --set ingress.enabled=true )
extraParams=("${extraParams[@]}" --set 'ingress.hosts[0].host='$EXPOSE_HOST',ingress.hosts[0].paths[0].path=/,ingress.hosts[0].paths[0].pathType=Prefix' )
fi
if [ -n "$CERT_NAME" ]; then
extraParams=("${extraParams[@]}" --set ingress.annotations."networking\.gke\.io/managed-certificates"=$CERT_NAME)
extraParams=("${extraParams[@]}" --set ingress.annotations."networking\.gke\.io/v1beta1\.FrontendConfig"="ssl-redirect")
fi
if [ -n "$BACKEND_CONFIG" ]; then
extraParams=("${extraParams[@]}" --set service.annotations."cloud\.google\.com/backend-config"='\{\"default\":\"'$BACKEND_CONFIG'\"\}')
fi
helm repo add kubeshop https://kubeshop.github.io/helm-charts
helm repo update
helm upgrade --install $NAME kubeshop/tracetest \
--namespace $NAME --create-namespace \
--set image.tag=$TAG \
--set image.pullPolicy=Always \
${extraParams[@]}
PROVISION_FILE=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)/provisioning.yaml
kubectl --namespace $NAME create configmap $NAME --from-file=$CONFIG_FILE --from-file=$PROVISION_FILE -o yaml --dry-run=client \
| envsubst \
| sed 's#'$(basename $CONFIG_FILE)'#config.yaml#' \
| kubectl --namespace $NAME replace -f -
kubectl --namespace $NAME delete pods -l app.kubernetes.io/name=tracetest
TIME_OUT=30m
CONDITION='[[ $(kubectl get pods --namespace '$NAME' -lapp.kubernetes.io/name=tracetest -o jsonpath="{.items[*].status.phase}") = "Running" ]]'
IF_TRUE='echo "pods ready"'
IF_FALSE='echo "pods not ready. retrying"'
ROOT_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}")/.. && pwd)
$ROOT_DIR/scripts/wait.sh "$TIME_OUT" "$CONDITION" "$IF_TRUE" "$IF_FALSE"