kubespray/contrib/dind/run-test-distros.sh

47 lines
1.7 KiB
Bash
Raw Normal View History

[jjo] add DIND support to contrib/ (#3468) * [jjo] add DIND support to contrib/ - add contrib/dind with ansible playbook to create "node" containers, and setup them to mimic host nodes as much as possible (using Ubuntu images), see contrib/dind/README.md - nodes' /etc/hosts editing via `blockinfile` and `lineinfile` need `unsafe_writes: yes` because /etc/hosts are mounted by docker, and thus can't be handled atomically (modify copy + rename) * dind-host role: set node container hostname on creation * add "Resulting deployment" section with some CLI outputs * typo * selectable node_distro: debian, ubuntu * some fixes for node_distro: ubuntu * cpu optimization: add early `pkill -STOP agetty` * typo * add centos dind support ;) * add kubespray-dind.yaml, support fedora - add kubespray-dind.yaml (former custom.yaml at README.md) - rework README.md as per above - use some YAML power to share distros' commonality - add fedora support * create unique /etc/machine-id and other updates - create unique /etc/machine-id in each docker node, used as seed for e.g. weave mac addresses - with above, now netchecker 100% passes WoHooOO! :tada: :tada: :tada: - updated README.md output from (1.12.1, verified netcheck) * minor typos * fix centos node creation, needs earlier udevadm removal to avoid flaky facts, also verified netcheck Ok \o/ * add Q&D test-distros.sh, back to manual /etc/machine-id hack * run-test-distros.sh cosmetics and minor fixes * run-test-distros.sh: $rc fix and minor formatting changes * run-test-distros.sh output cosmetics
2018-10-15 15:44:02 +08:00
#!/bin/bash
# Q&D test'em all: creates full DIND kubespray deploys
# for each distro, verifying it via netchecker.
pass_or_fail() {
local rc="$?"
local msg="$*"
local date="$(date -Isec)"
[ $rc -eq 0 ] && echo "PASS: [$date] $msg" || echo "FAIL: [$date] $msg"
}
test_distro() {
local distro=${1:?}
ansible-playbook -i hosts dind-cluster.yaml --extra-vars node_distro=$distro
pass_or_fail "$distro: dind-nodes"
(cd ../..
INVENTORY_DIR=inventory/local-dind
mkdir -p ${INVENTORY_DIR}
rm -f ${INVENTORY_DIR}/hosts.ini
CONFIG_FILE=${INVENTORY_DIR}/hosts.ini /tmp/kubespray.dind.inventory_builder.sh
ansible-playbook --become -e ansible_ssh_user=$distro -i \
${INVENTORY_DIR}/hosts.ini cluster.yml \
--extra-vars @contrib/dind/kubespray-dind.yaml --extra-vars bootstrap_os=$distro
pass_or_fail "$distro: kubespray"
)
docker exec kube-node1 kubectl get pod --all-namespaces
pass_or_fail "$distro: kube-api"
let n=60
while ((n--)); do
docker exec kube-node1 curl -s http://localhost:31081/api/v1/connectivity_check | grep successfully && break
sleep 2
done
[ $n -ge 0 ]
pass_or_fail "$distro: netcheck"
}
# Get all DISTROS from distro.yaml if $* unset (shame no yaml parsing, but nuff anyway)
DISTROS="${*:-$(egrep -o '^ \w+' group_vars/all/distro.yaml|paste -s)}"
NODES="$(egrep ^kube-node hosts|paste -s)"
echo "DISTROS=${DISTROS}"
for distro in ${DISTROS}; do
docker rm -f ${NODES}
{ time test_distro ${distro} ;} |& tee test-${distro}.out
# sleeping for the sake of the human to verify if they want
sleep 2m
done
egrep '^(PASS:|FAIL:|real)' $(ls -tr test-*out)