Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/update-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ on:

jobs:
update-kubernetes:
if: github.repository == 'kr8s-org/kr8s'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Update Kubernetes
env:
# Set optional secrets for Docker Hub authentication
# If not set, the script will not attempt to authenticate with Docker Hub
# but may run into rate limiting errors from Docker Hub.
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME || '' }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN || '' }}
run: uv run ./ci/update-kubernetes.py
- name: Show diff
id: diff
Expand Down
27 changes: 26 additions & 1 deletion ci/update-kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,37 @@ def extend_versions(versions, extended_versions, provider):
return versions


def dockerhub_auth():
if not os.environ.get("DOCKERHUB_USERNAME") or not os.environ.get(
"DOCKERHUB_TOKEN"
):
return None
data = json.dumps(
{
"identifier": os.environ.get("DOCKERHUB_USERNAME"),
"secret": os.environ.get("DOCKERHUB_TOKEN"),
}
).encode()
req = urllib.request.Request(
"https://hub.docker.com/v2/auth/token",
data=data,
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as resp:
return json.load(resp)["access_token"]


def get_kind_versions():
print("Loading Kubernetes tags from https://hub.docker.com/r/kindest/node/tags...")
container_tags = []
headers = {}
jwt_token = dockerhub_auth()
if jwt_token:
headers = {"Authorization": f"Bearer {jwt_token}"}
next_url = "https://hub.docker.com/v2/repositories/kindest/node/tags"
while next_url:
with urllib.request.urlopen(next_url) as url:
req = urllib.request.Request(next_url, headers=headers)
with urllib.request.urlopen(req) as url:
results = json.load(url)
container_tags += results["results"]
if "next" in results and results["next"]:
Expand Down