kubernetes-sigs/kubespray
View on GitHubVersion comparison crash in validate_inventory when kube_version has 'v' prefix
Open
#13163 opened on Apr 11, 2026
help wantedlifecycle/rotten
Description
Bug Report
Environment
- Kubespray: master branch (cloned 2026-04-11)
- Ansible: 11.13.0 (ansible-core 2.18.15)
- OS: Ubuntu 24.04 (nodes), macOS (controller)
- Python: 3.14
Description
When running cluster.yml with a kube_version that uses a v prefix (e.g. v1.31.4) and that version is older than the minimum supported, the version comparison in validate_inventory crashes with a Python type error instead of showing the intended human-readable error message.
Error
TASK [validate_inventory : Stop if unsupported version of Kubernetes]
fatal: [k8s-control-1]: FAILED! => {
"msg": "The conditional check 'kube_version is version(kube_version_min_required, '>=')' failed.
The error was: Version comparison failed: '<' not supported between instances of 'str' and 'int'"
}
Root Cause
In roles/kubespray_defaults/defaults/main/main.yml:
kube_version_min_required: "{{ (kubelet_checksums['amd64'] | dict2items)[-1].key }}"
This produces a bare version string like 1.33.4 (no v prefix). When compared against a user-supplied kube_version: v1.31.4 (with v prefix), the Jinja2 version filter fails with a type error instead of performing a proper semantic version comparison.
Expected Behavior
The assertion should either:
- Strip the
vprefix before comparison, or - Produce the intended error message: "The current release of Kubespray only support newer version of Kubernetes than X - You are trying to apply Y"
Steps to Reproduce
- Clone Kubespray master
- Set
kube_version: v1.31.4in group vars (any version older than the minimum and withvprefix) - Run
ansible-playbook cluster.yml
Context
I'm testing this in my home lab environment and ran into this while upgrading from Kubespray v2.26.0 to master.