forked from dptech-corp/dflow
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathinstall-linux.sh
112 lines (100 loc) · 2.85 KB
/
install-linux.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
#!/bin/bash
function INFO() {
echo "[INFO] $@"
}
function WARNING() {
echo >&2 "[WARNING] $@"
}
function ERROR() {
echo >&2 "[ERROR] $@"
}
docker_path=$(which docker)
if [[ -n "$docker_path" ]]; then
INFO "Found docker executable at $docker_path"
else
INFO "Docker not found, installing docker..."
sh -c "$(curl -fsSL https://get.docker.com/)"
if [[ $? != 0 ]]; then
ERROR "Fail to install docker"
exit 1
fi
fi
minikube_path=$(which minikube)
if [[ -n "$minikube_path" ]]; then
INFO "Found minikube binary at $minikube_path"
else
INFO "Minikube not found, installing minikube..."
curl -o minikube -L https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
if [[ $? != 0 ]]; then
ERROR "Fail to download minikube"
exit 1
fi
sudo install minikube /usr/local/bin/minikube
if [[ $? != 0 ]]; then
ERROR "Fail to install minikube"
exit 1
fi
fi
kubectl=$(which kubectl)
if [[ $? != 0 ]]; then
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
if [[ $? != 0 ]]; then
ERROR "Fail to download kubectl"
exit 1
fi
sudo install kubectl /usr/local/bin/kubectl
if [[ $? != 0 ]]; then
ERROR "Fail to install kubectl"
exit 1
fi
fi
minikube status 1>/dev/null 2>/dev/null
if [[ $? < 2 ]]; then
INFO "Minikube has been started"
else
INFO "Starting minikube..."
minikube start $@
if [[ $? != 0 ]]; then
ERROR "Fail to start minikube"
exit 1
fi
fi
kubectl create ns argo 1>/dev/null 2>/dev/null
kubectl apply -n argo -f https://raw.githubusercontent.com/deepmodeling/dflow/master/manifests/quick-start-postgres-3.4.1-deepmodeling.yaml 1>/dev/null
if [[ $? != 0 ]]; then
ERROR "Fail to apply argo yaml"
exit 1
fi
function waitForReady() {
while true; do
ready=$(kubectl get deployment $1 -n argo -o jsonpath='{.status.readyReplicas}')
replicas=$(kubectl get deployment $1 -n argo -o jsonpath='{.status.replicas}')
if [[ $? != 0 ]]; then
ERROR "Fail to get status of $1"
exit 1
fi
if [[ $replicas > 0 && $ready == $replicas ]]; then
INFO "$1 has been ready..."
break
fi
INFO "Waiting for $1 ready..."
sleep 3
done
}
waitForReady argo-server
waitForReady minio
waitForReady postgres
waitForReady workflow-controller
function forward() {
pid=`ps -ef | grep port-forward | grep $1 | grep $2 | awk '{print $2}'`
if [[ -n "$pid" ]]; then
kill -9 $pid
fi
INFO "Forwarding $1:$2 to localhost:$2"
nohup kubectl -n argo port-forward deployment/$1 $2:$2 --address 0.0.0.0 &
}
forward argo-server 2746
forward minio 9000
forward minio 9001
sleep 3
INFO "dflow server has been installed successfully!"