-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·62 lines (51 loc) · 1.54 KB
/
entrypoint.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
#!/bin/bash
set -e -v
eval set -- $(sed -e "s/%{KUBERNETES_API}%/${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}/g" <<< "${@@Q}")
set +v -x
cp /var/run/secrets/kubernetes.io/serviceaccount/ca.crt /usr/local/share/ca-certificates/
update-ca-certificates
tiller --listen=127.0.0.1:44134 --storage=secret &
export HELM_HOST=127.0.0.1:44134
helm init --skip-refresh --client-only
helm repo update --strict || helm repo remove stable
if [ -n "$REPO" ]; then
helm repo add ${NAME%%/*} $REPO
fi
helm repo update
JQ_CMD='"\(.Releases[0].AppVersion),\(.Releases[0].Status)"'
LINE="$(helm ls --all "^$NAME\$" --output json | jq -r "$JQ_CMD")"
INSTALLED_VERSION=$(echo $LINE | cut -f1 -d,)
STATUS=$(echo $LINE | cut -f2 -d,)
if [ -e /config/values.yaml ]; then
VALUES="--values /config/values.yaml"
fi
if [ "$1" = "delete" ]; then
if [ -z "$INSTALLED_VERSION" ]; then
exit
fi
helm delete $NAME || true
helm "$@"
exit
fi
if [ -z "$INSTALLED_VERSION" ] && [ -z "$STATUS" ]; then
helm "$@" $VALUES
exit
fi
if [ -z "$VERSION" ] || [ "$INSTALLED_VERSION" = "$VERSION" ]; then
if [ "$STATUS" = "DEPLOYED" ]; then
echo Already installed $NAME, upgrading
# We assume the args are always install --name foo CHART
shift 2
helm upgrade "$@" $VALUES
exit
fi
fi
if [ "$STATUS" = "FAILED" ] || [ "$STATUS" = "DELETED" ]; then
helm delete --purge $NAME
echo Deleted
helm "$@" $VALUES
exit
fi
# We assume the args are always install --name foo CHART
shift 2
helm upgrade "$@" $VALUES