-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathistio.sh
executable file
·84 lines (74 loc) · 2.03 KB
/
istio.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
#!/bin/bash
if [[ "$OSTYPE" == "linux-gnu" ]]; then
OS="linux"
ARCH="linux-amd64"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="osx"
ARCH="darwin-amd64"
fi
ISTIO_VERSION=1.0.4
HELM_VERSION=2.11.0
check_tiller () {
POD=$(kubectl get pods --all-namespaces|grep tiller|awk '{print $2}'|head -n 1)
kubectl get pods -n kube-system $POD -o jsonpath="Name: {.metadata.name} Status: {.status.phase}" > /dev/null 2>&1 | grep Running
}
pre_reqs () {
curl -sL "https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istio-$ISTIO_VERSION-$OS.tar.gz" | tar xz
if [ ! -f /usr/local/bin/istioctl ]; then
echo "Installing istioctl binary"
chmod +x ./istio-$ISTIO_VERSION/bin/istioctl
sudo mv ./istio-$ISTIO_VERSION/bin/istioctl /usr/local/bin/istioctl
fi
if [ ! -f /usr/local/bin/helm ]; then
echo "Installing helm binary"
curl -sL "https://storage.googleapis.com/kubernetes-helm/helm-v$HELM_VERSION-$ARCH.tar.gz" | tar xz
chmod +x $ARCH/helm
sudo mv linux-amd64/helm /usr/local/bin/
fi
}
install_tiller () {
echo "Checking if tiller is running"
check_tiller
if [ $? -eq 0 ]; then
echo "Tiller is installed and running"
else
echo "Deploying tiller to the cluster"
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
EOF
helm init --service-account tiller
fi
check_tiller
while [ $? -ne 0 ]; do
echo "Waiting for tiller to be ready"
sleep 30
done
}
install () {
echo "Deploying istio"
helm install istio-$ISTIO_VERSION/install/kubernetes/helm/istio --name istio --namespace istio-system \
--set global.controlPlaneSecurityEnabled=true \
--set grafana.enabled=true \
--set tracing.enabled=true \
--set kiali.enabled=true
}
pre_reqs
install_tiller
install