4 LIBDIR="$(dirname "$(dirname "$PWD")")"
6 source $LIBDIR/env/lib/common.sh
8 export KUBESPRAY_VERSION=2.16.0
10 function get_kud_repo {
12 export KUD_ADDONS=multus
15 function set_ssh_key {
16 if ! [ -f ~/.ssh/id_rsa ]; then
17 echo "Generating rsa key for this host"
18 ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa <&-
21 if ! grep -qF "$(ssh-keygen -y -f ~/.ssh/id_rsa)" ~/.ssh/authorized_keys; then
22 ssh-keygen -y -f ~/.ssh/id_rsa >> ~/.ssh/authorized_keys
25 chmod og-wx ~/.ssh/authorized_keys
29 pushd ${KUDPATH}/kud/hosting_providers/vagrant/inventory
30 HOST_IP=${HOST_IP:-$(hostname -I | cut -d ' ' -f 1)}
32 if [[ ! -z "${DOCKER_REGISTRY_MIRRORS+x}" ]]; then
34 for mirror in ${DOCKER_REGISTRY_MIRRORS}; do
35 OPTIONS="${OPTIONS} --registry-mirror=${mirror}"
37 DOCKER_OPTIONS="docker_options=\"${OPTIONS# }\""
41 $HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22 ${DOCKER_OPTIONS}
52 [k8s-cluster:children]
59 function kud_install {
60 pushd ${KUDPATH}/kud/hosting_providers/vagrant/
61 ./installer.sh | tee kud_deploy.log
66 pushd ${KUDPATH}/kud/hosting_providers/vagrant/
67 ansible-playbook -i inventory/hosts.ini /opt/kubespray-${KUBESPRAY_VERSION}/reset.yml \
68 --become --become-user=root -e reset_confirmation=yes
73 APISERVER=$(kubectl config view --minify -o \
74 jsonpath='{.clusters[0].cluster.server}')
75 TOKEN=$(kubectl get secret \
76 $(kubectl get serviceaccount default -o \
77 jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | \
79 call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
82 if [ "$1" == "reset" ] ; then