-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy.sh
executable file
·134 lines (109 loc) · 4.05 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
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
129
130
131
132
133
134
#!/bin/bash
set -e
if [ -z "`kubectl version`" ]; then
echo "kubectl is not installed, aborting"
exit 1
fi
echo "Detecting Kubernetes installation..."
KUBECFG=`kubectl config view --minify=true`
USEINGRESS=false
if echo "${KUBECFG}" | grep "name: minikube" > /dev/zero; then
echo "Kubernetes on Minikube detected!"
else
if echo "${KUBECFG}" | grep -e '^ *server:.*azmk8s\.io:443$' > /dev/zero; then
echo "Kubernetes on AKS detected!"
USEINGRESS=true
else
if echo "${KUBECFG}" | grep "name: gke_" > /dev/zero; then
echo "Kubernetes on GKE detected!"
USEINGRESS=true
else
echo "No specific Kubernetes provider detected, assuming Kubernetes runs on bare metal!"
fi
fi
fi
if [ ${USEINGRESS} = true ]
then
echo "Will use an ingress to enable access to kube-alive."
else
export KUBEALIVE_PUBLICIP=`kubectl config view --minify=true | grep "server: http" | sed 's/ *server: http:\/\///' | sed 's/ *server: https:\/\///' | sed 's/:.*//'`
echo "Will use a Service with external IP ${KUBEALIVE_PUBLICIP} to enable access to kube-alive."
fi
ARCHSUFFIX=
LOCAL=0
if [ $# -eq 1 ] && [ $1 = "local" ]; then
LOCAL=1
if uname -a | grep arm64 > /dev/null; then
ARCHSUFFIX=_arm64v8
else
if uname -a | grep arm > /dev/null; then
ARCHSUFFIX=_arm32v7
else
ARCHSUFFIX=_amd64
fi
fi
echo "Deploying locally for architecture ${ARCHSUFFIX} from deploy/."
if [ ! -n "${KUBEALIVE_DOCKER_REPO}" ]; then
echo "\$KUBEALIVE_DOCKER_REPO not set, aborting."
exit 1
else
echo "Using docker repo \"${KUBEALIVE_DOCKER_REPO}\"."
fi
else
echo "Deploying from github."
if [ ! -n "${KUBEALIVE_DOCKER_REPO}" ]; then
echo "\$KUBEALIVE_DOCKER_REPO not set, using \"kubealive\" as a default."
export KUBEALIVE_DOCKER_REPO=kubealive
else
echo "Using docker repo \"${KUBEALIVE_DOCKER_REPO}\"."
fi
fi
if [ -z "${KUBEALIVE_BRANCH}" ]; then
BRANCH_SUFFIX=
else
BRANCH_SUFFIX="_${KUBEALIVE_BRANCH}"
fi
for service in `echo "namespace
getip
healthcheck
cpuhog
incver
frontend"`; do
if [ ${LOCAL} -eq 1 ]; then
cat "./deploy/${service}.yml" | sed "s/%%KUBEALIVE_DOCKER_REPO%%/${KUBEALIVE_DOCKER_REPO}/" | sed "s/%%ARCHSUFFIX%%/${ARCHSUFFIX}/" | sed "s/%%BRANCH_SUFFIX%%/${BRANCH_SUFFIX}/" | kubectl apply -f -
else
curl -sSL "https://raw.githubusercontent.com/daniel-kun/kube-alive/master/deploy/${service}.yml" | sed "s/%%KUBEALIVE_DOCKER_REPO%%/${KUBEALIVE_DOCKER_REPO}/" | sed "s/%%ARCHSUFFIX%%/${ARCHSUFFIX}/" | sed "s/%%BRANCH_SUFFIX%%/${BRANCH_SUFFIX}/" | kubectl apply -f -
fi
done
if [ ${USEINGRESS} = true ]
then
if [ ${LOCAL} -eq 1 ]; then
kubectl apply -f ./deploy/ingress.yml
else
kubectl apply -f "https://raw.githubusercontent.com/daniel-kun/kube-alive/master/deploy/ingress.yml"
fi
echo "
FINISHED!
If you have an ingress controller installed, you should be able to access kube-alive through the ingresses external IP soon.
THIS CAN TAKE UP TO 10 MINUTES to work properly and requests may result in 500s or 404s in the meantime.
If you don't have an ingress controller installed, yet, you should install one now.
Either using helm:
helm install stable/nginx-ingress
or using the official nginx-ingress docs on
https://github.com/kubernetes/ingress-nginx/blob/master/deploy/README.md
"
else
if [ ${LOCAL} -eq 1 ]; then
cat ./deploy/external-ip.yml | sed "s/%%KUBEALIVE_PUBLICIP%%/${KUBEALIVE_PUBLICIP}/" | kubectl apply -f -
else
curl -sSL "https://raw.githubusercontent.com/daniel-kun/kube-alive/master/deploy/external-ip.yml" | sed "s/%%KUBEALIVE_PUBLICIP%%/${KUBEALIVE_PUBLICIP}/" | kubectl apply -f -
fi
echo "
FINISHED!
You should now be able to access kube-alive at
http://${KUBEALIVE_PUBLICIP}/
"
fi
echo "Also, you can look at all those neat Kubernetes resources that havee been created via
kubectl get all -n kube-alive
"