-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathsetup-sut-k8s.sh
More file actions
executable file
·110 lines (101 loc) · 3.86 KB
/
setup-sut-k8s.sh
File metadata and controls
executable file
·110 lines (101 loc) · 3.86 KB
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
#!/bin/bash -e
#
# Apache v2 license
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
DIR="$( cd "$( dirname "$0" )" &> /dev/null && pwd )"
. "$DIR"/setup-common.sh
print_help () {
echo "Usage: [options] <user@controller-ip[:private-ip]> <user>@worker-ip[:private-ip] [<user>@worker-ip[:private_ip]...]"
echo ""
echo "--port port Specify the ssh port."
echo "--nointelcert Do not install Intel certificates."
echo "--no-password Do not ask for password. Use DEV_SUDO_PASSWORD, SUT_SSH_PASSWORD and/or SUT_SUDO_PASSWORD instead."
echo "--worker Specify the worker group."
echo "--client Specify the client group."
echo "--controller Specify the controller group."
echo "--sut <file> Specify the sut configuration file."
echo ""
exit 3
}
if [ ${#@} -lt 2 ]; then
print_help
fi
parse_host_args --controller "$@"
setup_ansible_options=()
setup_native_options=()
ansible_options=(
'-e' 'k8s_reset=true'
'-e' 'containerd_reset=true'
'-e' 'k8s_enable_registry=false'
)
[ ! -e vars.yaml ] || ansible_options+=(-e "@vars.yaml")
last=""
for v in ${args[@]}; do
k1="$(echo "${v#--}" | cut -f1 -d=)"
v1="$(echo "${v#--}" | cut -f2- -d= | sed 's/%20/ /g')"
case "$v" in
--nointelcert)
setup_native_options+=("$v")
;;
--no-password)
setup_ansible_options+=("$v")
setup_native_options+=("$v")
;;
--*=*)
validate_ansible_option $k1 $v
setup_native_options+=("$v")
ansible_options+=("-e" "$k1=$v1")
;;
--no*)
validate_ansible_option ${k1#no} $v
setup_native_options+=("$v")
ansible_options+=("-e" "${k1#no}=false")
;;
--*)
validate_ansible_option $k1 $v
setup_native_options+=("$v")
ansible_options+=("-e" "$k1=true")
;;
*)
echo "Unsupported argument: $v"
exit 3
;;
esac
last="$v"
done
./setup-ansible.sh "${setup_ansible_options[@]}" 2>&1 | tee setup-sut-k8s.logs
./setup-sut-native.sh --port $ssh_port --controller ${controller_hosts[@]} --worker ${worker_hosts[@]} --client ${client_hosts[@]} "${setup_native_options[@]}" 2>&1 | tee -a setup-sut-k8s.logs
. <(sed '/^# BEGIN WSF Setup/,/^# END WSF Setup/{d}' /etc/environment)
export http_proxy https_proxy no_proxy
rm -f /tmp/wsf-setup-ssh-* 2> /dev/null || true
ANSIBLE_ROLES_PATH=../terraform/template/ansible/kubernetes/roles:../terraform/template/ansible/common/roles:../terraform/template/ansible/traces/roles ANSIBLE_INVENTORY_ENABLED=yaml ansible-playbook --flush-cache -vv -e mysut_config_name="$sutname" -e wl_logs_dir="$DIR" -e my_ip_list=1.1.1.1 "${ansible_options[@]}" --inventory <(create_inventory) ./setup-sut-k8s.yaml 2>&1 | tee -a setup-sut-k8s.logs
rm -f cluster-info.json timing.yaml
show_tf_file 2>&1 | tee -a setup-sut-k8s.logs
is_controller_on_dev_host () {
for h in ${controller_hosts[@]/:*/}; do
[[ " $@ " != *" ${h/*@/} "* ]] || echo true
done
}
if [[ "$(is_controller_on_dev_host $(hostname) $(hostname -f) $(hostname -i))" = *"true"* ]]; then
(
echo
echo "Kubernetes requires to use a docker REGISTRY to serve images. If you use only official release images,"
echo "then no more setup is required. Otherwise you must create a private registry (setup-reg.sh) and set it"
echo "as follows:"
echo " cd build"
echo " wsf-config -DREGISTRY=<value>"
) 2>&1 | tee -a setup-sut-k8s.logs
else
(
echo
echo "Kubernetes requires to use a docker REGISTRY to serve images. If you use only official release images,"
echo "then no more setup is required. Otherwise do one of the following setup steps:"
echo "(1) Setup a private registry (setup-reg.sh) and activate it as follows:"
echo " cd build"
echo " wsf-config -DREGISTRY=<value>"
echo "(2) Set 'k8s_enable_registry: true' in script/terraform/terraform-config.$sutname.tf. An in-cluster registry"
echo "will be created to serve images."
) 2>&1 | tee -a setup-sut-k8s.logs
fi