@@ -16,13 +16,15 @@ if [[ "$(whoami)" != "root" ]]; then
16
16
exit
17
17
fi
18
18
19
- echo " Docker pull dependency images ..."
19
+ echo " Docker pull dependency images, you can comment this if already have them ..."
20
20
# c.f. https://github.com/sql-machine-learning/sqlflow/blob/develop/.travis.yml
21
21
docker pull sqlflow/sqlflow:jupyter
22
22
docker pull sqlflow/sqlflow:mysql
23
23
docker pull sqlflow/sqlflow:server
24
24
docker pull sqlflow/sqlflow:step
25
25
docker pull argoproj/argoexec:v2.7.7
26
+ docker pull argoproj/argocli:v2.7.7
27
+ docker pull argoproj/workflow-controller:v2.7.7
26
28
echo " Done."
27
29
28
30
# NOTE: According to https://stackoverflow.com/a/16619261/724872,
@@ -40,15 +42,17 @@ set +e
40
42
# "$3" is expected output
41
43
function wait_until() {
42
44
echo -n " Waiting for $1 "
43
- while [[ true ]] ; do
45
+ for i in {1..50} ; do
44
46
$2 | grep -o -q " $3 "
45
47
if [[ $? -eq 0 ]]; then
46
- break
48
+ echo " Done"
49
+ return
47
50
fi
48
51
echo -n " ."
49
52
sleep 3
50
53
done
51
- echo " Done"
54
+ echo " Fail"
55
+ exit
52
56
}
53
57
54
58
# Use a faster kube image and docker registry
73
77
74
78
wait_until " minikube" " minikube status" " apiserver: Running"
75
79
76
- # Test if a Kubernetes resource is alive
80
+ # Test if a Kubernetes pod is ready
77
81
# "$1" shoulde be namespace id e.g. argo
78
- # "$2" should be resource id e.g. pod/argo-server
79
- function is_resource_alive() {
80
- local type=$( echo " $2 " | cut -d / -f1)
81
- local name=$( echo " $2 " | cut -d / -f2)
82
- if kubectl get -n " $1 " " $2 " 2> /dev/null | grep -q -o " $name " > /dev/null; then
83
- # make sure relative pod is alive
84
- if kubectl get pod -n " $1 " 2> /dev/null | grep " $name " | grep " Running" > /dev/null; then
85
- echo " yes"
86
- else
87
- echo " no"
88
- fi
82
+ # "$2" should be pod selector e.g. k8s-app=kubernetes-dashboard
83
+ function is_pod_ready() {
84
+ pod=$( kubectl get pod -n " $1 " -l " $2 " -o name | tail -1)
85
+ if [[ -z " $pod " ]]; then
86
+ echo " no"
87
+ return
88
+ fi
89
+ ready=$( kubectl get -n " $1 " " $pod " -o jsonpath=' {.status.containerStatuses[0].ready}' )
90
+ if [[ " $ready " == " true" ]]; then
91
+ echo " yes"
89
92
else
90
93
echo " no"
91
94
fi
92
95
}
93
96
94
97
echo " Start argo ..."
95
- argo_server_alive=$( is_resource_alive " argo" " service/ argo-server" )
98
+ argo_server_alive=$( is_pod_ready " argo" " app= argo-server" )
96
99
if [[ " $argo_server_alive " == " yes" ]]; then
97
100
echo " Already in running."
98
101
else
99
102
$( dirname $0 ) /sqlflow/scripts/travis/start_argo.sh
100
103
fi
101
- wait_until " argo" " is_resource_alive argo service/ argo-server" " yes"
104
+ wait_until " argo" " is_pod_ready argo app= argo-server" " yes"
102
105
103
106
echo " Strat Kubernetes Dashboard ..."
104
- dashboard_alive=$( is_resource_alive " kubernetes-dashboard" " service/ kubernetes-dashboard" )
107
+ dashboard_alive=$( is_pod_ready " kubernetes-dashboard" " k8s-app= kubernetes-dashboard" )
105
108
if [[ " $dashboard_alive " == " yes" ]]; then
106
109
echo " Already in running."
107
110
else
108
- nohup minikube dashboard &
111
+ nohup minikube dashboard > /dev/null 2>&1 &
109
112
fi
110
- wait_until " Kubernetes Dashboard" " is_resource_alive kubernetes-dashboard service/ kubernetes-dashboard" " yes"
113
+ wait_until " Kubernetes Dashboard" " is_pod_ready kubernetes-dashboard k8s-app= kubernetes-dashboard" " yes"
111
114
112
115
echo " Strat SQLFlow ..."
113
- sqlflow_alive=$( is_resource_alive " default" " pod/ sqlflow-server" )
116
+ sqlflow_alive=$( is_pod_ready " default" " app= sqlflow-server" )
114
117
if [[ " $sqlflow_alive " == " yes" ]]; then
115
118
echo " Already in running."
116
119
else
117
120
kubectl apply -f sqlflow/doc/run/k8s/install-sqlflow.yaml
118
121
fi
119
- wait_until " SQLFlow" " is_resource_alive default pod/ sqlflow-server" " yes"
122
+ # wait_until "SQLFlow" "is_pod_ready default app= sqlflow-server" "yes"
120
123
121
124
# Kill port exposing if it already exist
122
125
function stop_expose() {
0 commit comments