AIO and MUNO mode upgrade for EG 1.5.0 version
[eliot.git] / scripts / verifyk8s.sh
1 #!/bin/bash -ex
2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 NGINXDEP=~/testk8s-nginx.yaml
12
13 cat <<EOF > "${NGINXDEP}"
14 ---
15 apiVersion: apps/v1
16 kind: Deployment
17 metadata:
18   name: nginx-deployment
19   labels:
20     app: nginx
21 spec:
22   replicas: 1
23   selector:
24     matchLabels:
25       app: nginx
26   template:
27     metadata:
28       labels:
29         app: nginx
30     spec:
31       containers:
32         - name: nginx
33           image: nginx:1.15.12
34           ports:
35             - containerPort: 80
36               hostPort: 80
37 EOF
38
39 #check if nginx is already deployed
40 if ! kubectl get pods | grep nginx; then
41   kubectl create -f ~/testk8s-nginx.yaml
42 fi
43
44 #To check whether the deployment is succesesfull
45 retry=10
46 while [ $retry -gt 0 ]
47 do
48   if [ 2 == "$(kubectl get pods | grep -c -e STATUS -e Running)" ]; then
49     break
50   fi
51   ((retry-=1)) 
52   sleep 10
53 done
54 [ $retry -gt 0 ] || exit 1