-
Notifications
You must be signed in to change notification settings - Fork 38
/
install.sh
132 lines (123 loc) · 3.15 KB
/
install.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
INSTALL_TYPE=$1
: ${INSTALL_TYPE:=all}
# Common utilities, variables and checks for all scripts.
set -o errexit
set -o nounset
set -o pipefail
# Gather variables about bootstrap system
USR_BIN_PATH=/usr/local/bin
export PATH="${PATH}:${USR_BIN_PATH}"
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
# Define glob variables
KUBE_ROOT="$(cd "$(dirname "$0")" && pwd)"
CERTS_DIR="${KUBE_ROOT}/config/certs"
CONFIG_FILE="${KUBE_ROOT}/config.yaml"
CA_CONFIGFILE="${KUBE_ROOT}/config/rootCA.cnf"
COMPOSE_YAML_FILE="${KUBE_ROOT}/compose.yaml"
IMAGES_DIR="${KUBE_ROOT}/resources/images"
COMPOSE_CONFIG_DIR="${KUBE_ROOT}/config/compose"
OUTPUT_ENV_FILE="${KUBE_ROOT}/.install-env.sh"
RESOURCES_NGINX_DIR="${KUBE_ROOT}/resources/nginx"
KUBESPRAY_CONFIG_DIR="${KUBE_ROOT}/config/kubespray"
INSTALL_STEPS_FILE="${KUBESPRAY_CONFIG_DIR}/.install_steps"
# Include all functions from library/*.sh
for file in ${KUBE_ROOT}/library/*.sh; do source ${file}; done
# Gather os-release variables
if ! source /etc/os-release; then
errorlog "Every system that we officially support has /etc/os-release"
exit 1
fi
if [ ! -f ${CONFIG_FILE} ]; then
errorlog "The ${CONFIG_FILE} file is not existing"
exit 1
fi
deploy_compose(){
if grep -q 'deploy_compose' ${KUBE_ROOT}/.install_steps; then
common::rudder_config
common::load_images
common::health_check
return 0
fi
case ${ID} in
Debian|debian)
system::debian::config_repo
;;
CentOS|centos)
system::centos::disable_selinux
system::centos::config_repo
;;
Fedora|fedora)
system::fedora::disable_selinux
system::fedora::config_repo
;;
Ubuntu|ubuntu)
system::ubuntu::config_repo
;;
*)
errorlog "Not support system: ${ID}"
exit 1
;;
esac
system::disable_firewalld
system::install_pkgs
common::install_tools
common::rudder_config
common::update_hosts
system::install_chrony
common::generate_domain_certs
common::load_images
common::compose_up
common::health_check
echo 'deploy_compose' > ${KUBE_ROOT}/.install_steps
}
main(){
case ${INSTALL_TYPE} in
all)
deploy_compose
common::push_kubespray_image
common::run_kubespray "bash /kubespray/run.sh deploy-cluster"
;;
compose)
deploy_compose
;;
cluster)
common::rudder_config
common::push_kubespray_image
common::run_kubespray "bash /kubespray/run.sh deploy-cluster"
;;
remove)
common::rudder_config
remove::remove_cluster
remove::remove_compose
;;
remove-cluster)
common::rudder_config
remove::remove_cluster
;;
remove-compose)
common::rudder_config
remove::remove_compose
;;
add-node)
common::run_kubespray "bash /kubespray/run.sh add-node $2"
;;
remove-node)
common::run_kubespray "bash /kubespray/run.sh remove-node $2"
;;
health-check)
common::health_check
;;
debug)
common::run_kubespray "bash"
;;
-h|--help|help)
common::usage
;;
*)
echowarn "unknow [TYPE] parameter: ${INSTALL_TYPE}"
common::usage
;;
esac
}
main "$@"