Files
k3s-ansible/.github/workflows/test.yml
T
Techno Tim 287d8b7a27 feat(kube-vip): add endpoint override for the internal listening address (#699)
* feat(kube-vip): add endpoint override for the internal listening address

Add a kube_vip_endpoint variable so the address kube-vip binds and listens on
can differ from the announced apiserver_endpoint. This is useful for complex
routing and site-to-site tunnels where the VIP kube-vip advertises over ARP
differs from the address it listens on internally.

- roles/k3s_server/templates/vip.yaml.j2: use kube_vip_endpoint (defaulting to
  apiserver_endpoint) for the `address` env and for deriving `vip_subnet`
- roles/k3s_server/defaults/main.yml: add kube_vip_endpoint default (null)
- roles/k3s_server/meta/main.yml: add kube_vip_endpoint argument_spec
- inventory/sample/group_vars/all.yml: document the new sample variable
- README.md: document the kube_vip_endpoint option
- .github/scripts/test-kube-vip-manifest.py: extend regression test to cover the
  default (apiserver_endpoint) and the override case

Closes #221

* chore(ci): extend molecule job timeout to 3 hours

The default scenario occasionally takes longer than 150 minutes on the shared
nested-virt runner (k3s agent notify-wait can exceed the limit under load), and
a single timeout aborts the whole run before the other four scenarios execute.
Raise timeout-minutes from 150 to 180 so a slow-but-progressing run completes
instead of aborting.

The default scenario remains first in the matrix so a failure surfaces fastest.

* fix(kube-vip): fall back on null kube_vip_endpoint and cover it in the test

- vip_subnet and address use default(apiserver_endpoint, true) so the null
  role default falls back to the apiserver endpoint instead of rendering an
  empty/invalid address and subnet
- change the manifest regression test default case to pass kube_vip_endpoint
  as None so it pins the real runtime null condition and fails fast on this
  regression rather than timing out in CI
2026-08-06 02:48:57 -05:00

119 lines
4.2 KiB
YAML

---
name: Test
on:
workflow_call:
jobs:
molecule:
name: Molecule
runs-on: [self-hosted, linux, x64, k3s-ci, virtualbox, nested-virt]
strategy:
matrix:
scenario:
- default
- single_node
- calico
- cilium
- kube-vip
# - ipv6
fail-fast: true
max-parallel: 1
env:
PYTHON_VERSION: "3.11"
VAGRANT_DEFAULT_PROVIDER: virtualbox
VAGRANT_HOME: ${{ github.workspace }}/.vagrant-home
steps:
- name: Check out the codebase
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Clean repository-owned resources before testing
run: ./.github/scripts/cleanup-runner-resources.sh --apply
- name: Record host-only network baseline
run: ./.github/scripts/cleanup-runner-resources.sh --snapshot
- name: Check nested VirtualBox platform
run: |
set -Eeuo pipefail
grep -Eq 'vmx|svm' /proc/cpuinfo
test -c /dev/kvm
test -c /dev/vboxdrv
VBoxManage --version
vagrant --version
test -r /etc/vbox/networks.conf
test "$(stat -c '%u' /etc/vbox/networks.conf)" -eq 0
free -h
df -Pk "${RUNNER_TEMP}"
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # 7.0.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies
- name: Restore vagrant Boxes cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # 6.1.0
with:
path: .vagrant-home/boxes
key: vagrant-boxes-${{ runner.name }}-${{ runner.os }}-${{ runner.arch }}-virtualbox-7.2-vagrant-2.4-${{ hashFiles('.github/vagrant-boxes.lock') }} # yamllint disable-line rule:line-length
fail-on-cache-miss: true
- name: Prepare runner-owned Vagrant box masters
run: ./.github/scripts/prepare-vagrant-box-masters.sh
- name: Install dependencies
run: |
echo "::group::Upgrade pip"
python3 -m pip install --upgrade pip
echo "::endgroup::"
echo "::group::Install Python requirements from requirements.txt"
python3 -m pip install -r requirements.txt
echo "::endgroup::"
- name: Test with molecule
run: |
set -Eeuo pipefail
resource_dir="${RUNNER_TEMP}/logs/resources/${{ matrix.scenario }}"
timing_file="${RUNNER_TEMP}/logs/timing/${{ matrix.scenario }}.txt"
mkdir -p -- "${timing_file%/*}"
./.github/scripts/monitor-runner-resources.sh "$resource_dir" 10 &
monitor_pid=$!
stop_monitor() {
kill -TERM "$monitor_pid" 2>/dev/null || true
wait "$monitor_pid" 2>/dev/null || true
}
trap stop_monitor EXIT
/usr/bin/time -v -o "$timing_file" \
molecule test --scenario-name ${{ matrix.scenario }}
timeout-minutes: 180
env:
ANSIBLE_K3S_LOG_DIR: ${{ runner.temp }}/logs/k3s-ansible/${{ matrix.scenario }}
ANSIBLE_SSH_RETRIES: 4
ANSIBLE_TIMEOUT: 120
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
K3S_CI_CREATE_TIMING_LOG: ${{ runner.temp }}/logs/timing/${{ matrix.scenario }}-create.log
- name: Collect runner diagnostics
if: always()
run: ./.github/scripts/collect-runner-diagnostics.sh "${RUNNER_TEMP}/logs/runner"
env:
K3S_CI_SCENARIO_NAME: ${{ matrix.scenario }}
- name: Clean repository-owned resources after testing
if: always()
run: ./.github/scripts/cleanup-runner-resources.sh --apply
- name: Upload log files
if: always() # do this even if a step before has failed
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # 7.0.1
with:
name: logs-${{ matrix.scenario }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/logs
if-no-files-found: warn
retention-days: 14