Logs added with msgs
[ealt-edge.git] / ci / daily build / csit / verifyPods.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 KUBERNETES=~/testk8s-kubernetes.yaml
12
13 cat <<EOF > "${KUBERNETES}"
14 ---
15 apiVersion: apps/v1
16 kind: Deployment
17 metadata:
18   name: kubernets-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 kubernetes is already running
40 if ! kubectl cluster-info ; then
41   kubectl create -f ~/testk8s-kubernetes.yaml
42 fi
43
44 #To check the pods which is not running
45 if kubectl get pods | grep -c -e STATUS -e Running > 0; then
46 PODS_NOT_RUNNING=$(kubectl get pods --field-selector=status.phase!=Running)
47 fi
48
49 echo "-------------------------------------------------------------------"
50 echo
51 echo $PODS_NOT_RUNNING > /dev/null 2>&1
52 echo
53 echo "-------------------------------------------------------------------"