-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanity-check.sh
executable file
·87 lines (78 loc) · 2.94 KB
/
sanity-check.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
#!/bin/bash
# Early out on combinations that won't work.
source config.sh
echo "$(date) - Checking input."
# K8s nodes.
if [ "$worker_nodes" -lt 1 ] || [ $((worker_nodes%2)) -eq 0 ];
then
echo "$(date) - ERROR: The number of worker nodes ($worker_nodes) should be a positive odd number."
exit 1
else
echo "$(date) - Validated number of worker nodes: $worker_nodes."
fi
if [ "$control_nodes" -lt 1 ] || [ $((control_nodes%2)) -eq 0 ];
then
echo "$(date) - ERROR: The number of control plane nodes ($control_nodes) should be a positive odd number."
exit 1
else
echo "$(date) - Validated number of control plane nodes: $control_nodes."
fi
# RZA.
if [ "$rackzone_aware" == "yes" ];
then
if [ "$rackzone_zones" -lt 1 ] || [ $((rackzone_zones%2)) -eq 0 ];
then
echo "$(date) - ERROR: The number of rack zones ($rackzone_zones) should be a positive odd number."
exit 1
else
echo "$(date) - Validated number of rack zone: $rackzone_zones."
fi
if [ "$worker_nodes" -lt "$rackzone_zones" ];
then
echo "$(date) - ERROR: The number of worker nodes ($worker_nodes) is not capable of hosting all rack zones ($rackzone_zones)."
exit 1
else
echo "$(date) - Validated the number of worker nodes ($worker_nodes) is capable of hosting all rack zones ($rackzone_zones)."
fi
ideal_workers=$((rackzone_zones*2 - 1))
if [ ! "$ideal_workers" -eq "$worker_nodes" ];
then
echo "$(date) - WARN: The number of worker nodes ($worker_nodes) is sub optimal for rack zones ($rackzone_zones). Ideal number of worker nodes: $ideal_workers."
else
echo "$(date) - Validated the number of worker nodes ($worker_nodes) is ideal for the number of rack zones ($rackzone_zones)."
fi
fi
# Number of clusters.
if [ "$num_clusters" -lt 1 ]; then
echo "$(date) - ERROR: The number of clusters should be at least equal to 1."
exit 1
fi
if [ "$num_clusters" -gt 3 ]; then
echo "$(date) - WARNING: This number of clusters ($num_clusters) has not been tested."
else
echo "$(date) - Validated number of clusters: $num_clusters."
fi
# A/A prerequisites.
if [ "$active_active" == "yes" ]; then
if [[ "$install_loadbalancer" != "yes" || "$install_ingress" != "yes" || "$patch_dns" != "yes" ]]; then
echo "$(date) - ERROR: Active / Active requires a loadbalancer, ingress, and DNS patching."
exit 1
else
echo "$(date) - Validated Active / Active prerequisites."
fi
if [ "$num_clusters" -eq 1 ]; then
echo "$(date) - WARNING: Deploying a CRDB in 1 cluster will work, but will have limited functionality."
fi
fi
# Valid ingress.
if [ "$install_ingress" == "yes" ]; then
case "$ingresscontroller_type" in
"ingress-nginx" | "haproxy-ingress" | "nginx-ingress" | "contour")
echo "$(date) - Validated ingress controller type: $ingresscontroller_type."
;;
*)
echo "$(date) - ERROR: Invalid ingress controller $ingresscontroller_type."
exit 1
;;
esac
fi