blob: e61ca9451c1b7f5e976e84b4592f63e23ca33a45 (
plain)
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
|
#!/bin/bash -e
# shellcheck disable=SC1090
##############################################################################
# Copyright (c) 2019 Mirantis Inc., Enea AB and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/xdf_data.sh"
IEC_REPO_URI='https://gerrit.akraino.org/r/iec'
IEC_USER_L='ubuntu'
# shellcheck disable=SC2154
if [[ "${base_image}" =~ centos ]]; then
IEC_USER='centos'
else
IEC_USER=${IEC_USER_L}
fi
IEC_REPO_PATH=/var/lib/akraino/iec
IEC_SCRIPTS_PATH="${IEC_REPO_PATH}/src/foundation/scripts"
POD_NETWORK_CIDR='100.100.0.0/16' # Avoid overlapping Fuel's PXE/admin net
# shellcheck disable=SC2174
mkdir -p -m 777 "$(dirname ${IEC_REPO_PATH})"
[ -e "${IEC_REPO_PATH}" ] || su - "${IEC_USER_L}" -c \
"git clone '${IEC_REPO_URI}' '${IEC_REPO_PATH}'"
# shellcheck disable=SC2086
wait_for 3.0 "! salt-cp 'iec*' -C '${IEC_REPO_PATH}/' \
'$(dirname ${IEC_REPO_PATH})' | grep -e False"
salt -C 'iec*' cmd.run "chown -R ${IEC_USER}:${IEC_USER} ${IEC_REPO_PATH}"
salt -C 'iec*' cmd.run runas="${IEC_USER}" "${IEC_SCRIPTS_PATH}/k8s_common.sh"
IEC_MASTER_IP=$(salt --out txt -C 'iec* and *01*' pillar.get \
_param:single_address | cut -d ' ' -f2)
salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \
"${IEC_SCRIPTS_PATH}/k8s_master.sh ${IEC_MASTER_IP} ${POD_NETWORK_CIDR}"
KUBE_NODE_CNT=$(salt --out txt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \
'kubectl get nodes | grep -c -e "^iec"' | cut -d ' ' -f2)
if [ "${KUBE_NODE_CNT}" != "$(salt-key | grep -c -e '^iec')" ]; then
KUBE_JOIN_CMD=$(salt --out txt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \
'kubeadm token create --print-join-command' | cut -d ' ' -f2-)
salt -C 'iec* and not *01*' cmd.run "${KUBE_JOIN_CMD}"
fi
salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" 'kubectl get nodes'
salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" \
"${IEC_SCRIPTS_PATH}/setup-cni.sh '' ${POD_NETWORK_CIDR}"
salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" "${IEC_SCRIPTS_PATH}/nginx.sh"
salt -C 'iec* and *01*' cmd.run runas="${IEC_USER}" "${IEC_SCRIPTS_PATH}/helm.sh"
|