-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_verify_cluster.sh
84 lines (58 loc) · 2.66 KB
/
4_verify_cluster.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
#!/bin/sh
#!/bin/sh
FILE=../variables.sh && test -f $FILE && source $FILE
FILE=variables.sh && test -f $FILE && source $FILE
echo ""
echo ""
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "*********************verify cluster components************************"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
# Check etcd cluster components
# -----------------------------------------------------------------
echo "____________________________________________________________________________"
echo "verifying etcd cluster"
echo "____________________________________________________________________________"
# use the first node of etcd cluster
NODE_NAME=${CONTROL_PLANE_ETCD_NODES[0]}
# remove the node from host to avoid warning
ssh-keygen -q -f "/home/$USER/.ssh/known_hosts" -R $NODE_NAME
ssh -i $SSH_CERT -o StrictHostKeyChecking=no $SSH_USER@$NODE_NAME /bin/bash << EOF
sudo ETCDCTL_API=3 etcdctl member list \
--endpoints=https://127.0.0.1:2379 \
--cacert=/etc/etcd/ca.pem \
--cert=/etc/etcd/etcd.pem \
--key=/etc/etcd/etcd-key.pem
EOF
# Check k8s cluster components
# -----------------------------------------------------------------
echo "____________________________________________________________________________"
echo "verifying k8s componentstatus of cluster"
echo "____________________________________________________________________________"
kubectl get componentstatuses
echo "____________________________________________________________________________"
echo "verifying worker nodes "
echo "____________________________________________________________________________"
# use the first node of etcd cluster
sleep 3
kubectl get nodes -o wide
echo "____________________________________________________________________________"
echo "verifying system pods "
echo "____________________________________________________________________________"
# use the first node of etcd cluster
kubectl get pods -n kube-system -o wide
echo "____________________________________________________________________________"
echo "Deploy nginx pods "
echo "____________________________________________________________________________"
# use the first node of etcd cluster
echo "remove existing nginx deployment"
kubectl delete deployment ngx
echo "create nginx"
kubectl create deployment ngx --image=nginx
POD_NUM=$(shuf -i1-30 -n1)
echo "scale the deployment to $POD_NUM pods"
kubectl scale deployment ngx --replicas=$POD_NUM
echo "wait 10 seconds for pods to start"
sleep 10
kubectl get pods -o wide
kubectl get deployment ngx
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"