Skip to content

Commit

Permalink
Find latest available kind image for each supported version (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson authored Nov 2, 2023
1 parent fb313e9 commit b5b182f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:
kubernetes-version: 1.27.3
- python-version: '3.10'
kubernetes-version: 1.26.6
- python-version: '3.10'
kubernetes-version: 1.25.11
env:
KUBECONFIG: .pytest-kind/pytest-kind/kubeconfig

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Read the Docs](https://img.shields.io/readthedocs/kr8s?logo=readthedocs&logoColor=white)](https://kr8s.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://img.shields.io/pypi/v/kr8s)](https://pypi.org/project/kr8s/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kr8s)](https://pypi.org/project/kr8s/)
[![Kubernetes Version Support](https://img.shields.io/badge/Kubernetes%20support-1.25%7C1.26%7C1.27%7C1.28-blue)](https://docs.kr8s.org/en/latest/installation.html#supported-kubernetes-versions)
[![Kubernetes Version Support](https://img.shields.io/badge/Kubernetes%20support-1.26%7C1.27%7C1.28-blue)](https://docs.kr8s.org/en/latest/installation.html#supported-kubernetes-versions)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/kr8s)](https://pypi.org/project/kr8s/)
[![PyPI - License](https://img.shields.io/pypi/l/kr8s)](https://pypi.org/project/kr8s/)

Expand Down
38 changes: 32 additions & 6 deletions ci/update-kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,49 @@ def get_versions():
data = [
{
"cycle": x["cycle"],
"version": x["latest"],
"latest_version": x["latest"],
"eol": datetime.strptime(x["eol"], DATE_FORMAT),
}
for x in data
if datetime.strptime(x["eol"], DATE_FORMAT) > datetime.now()
]
data.sort(key=lambda x: x["eol"], reverse=True)
return data

print("Loading Kubernetes tags from https://hub.docker.com/r/kindest/node/tags...")
with urllib.request.urlopen(
"https://hub.docker.com/v2/repositories/kindest/node/tags"
) as url:
container_tags = json.load(url)

for version in data:
try:
version["latest_kind_container"] = [
x["name"]
for x in container_tags["results"]
if version["cycle"] in x["name"]
][0][1:]
except IndexError:
version["latest_kind_container"] = None

before_length = len(data)
print("Pruning versions that do not have a kind release yet...")
data[:] = [x for x in data if x["latest_kind_container"] is not None]
print(f"Pruned {before_length - len(data)} versions")
return data


def update_test_workflow(versions):
workflow = yaml.load(Path(".github/workflows/test.yaml"))
workflow["jobs"]["test"]["strategy"]["matrix"]["kubernetes-version"][0] = versions[
0
]["version"]
]["latest_kind_container"]
workflow["jobs"]["test"]["strategy"]["matrix"]["include"] = []
for version in versions[1:]:
workflow["jobs"]["test"]["strategy"]["matrix"]["include"].append(
{"python-version": "3.10", "kubernetes-version": version["version"]}
{
"python-version": "3.10",
"kubernetes-version": version["latest_kind_container"],
}
)
yaml.dump(workflow, Path(".github/workflows/test.yaml"))

Expand All @@ -64,10 +88,12 @@ def update_badges(filename, versions):

def main():
versions = get_versions()
print(f"Latest version: {versions[0]['version']}")
print(f"Latest version: {versions[0]['cycle']}")
print("Supported versions:")
for version in versions:
print(f"{version['version']} until {version['eol']}")
print(
f"For {version['cycle']} using kindest/node {version['latest_kind_container']} until {version['eol']}"
)

update_test_workflow(versions)
update_badges("README.md", versions)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI](https://img.shields.io/pypi/v/kr8s)](https://pypi.org/project/kr8s/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kr8s)](https://pypi.org/project/kr8s/)
[![Kubernetes Version Support](https://img.shields.io/badge/Kubernetes%20support-1.25%7C1.26%7C1.27%7C1.28-blue)](https://docs.kr8s.org/en/latest/installation.html#supported-kubernetes-versions)
[![Kubernetes Version Support](https://img.shields.io/badge/Kubernetes%20support-1.26%7C1.27%7C1.28-blue)](https://docs.kr8s.org/en/latest/installation.html#supported-kubernetes-versions)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/kr8s)](https://pypi.org/project/kr8s/)
[![PyPI - License](https://img.shields.io/pypi/l/kr8s)](https://pypi.org/project/kr8s/)
<iframe src="https://ghbtns.com/github-btn.html?user=kr8s-org&repo=kr8s&type=star&count=true" frameborder="0" scrolling="0" width="150" height="20" title="GitHub"></iframe>
Expand Down

0 comments on commit b5b182f

Please sign in to comment.