Skip to content

Commit 77474f5

Browse files
Synchronize automatically kube-proxy images (#395)
Add a new scheduled workflow (sync-kube-proxy-images.yaml) that runs daily at 00:00 UTC (2 hours before test-kube-proxy-images.yml) to detect missing kube-proxy images starting 1.33 (currently the oldest supported kubernetes version). For each missing version it trigges build-kube-proxy-images.yml via workflow_dispatch. Also updates build-kube-proxy-images.yml so that the repository is now a configurable input so that changes can be tested on local branches. Signed-off-by: Juan-Luis de Sousa-Valadas Castaño <jvaladas@mirantis.com>
1 parent b3efa00 commit 77474f5

File tree

2 files changed

+106
-3
lines changed

2 files changed

+106
-3
lines changed

.github/workflows/build-kube-proxy-images.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,25 @@ on:
77
proxy_version:
88
description: 'Version of kube-proxy to build (ex: v1.27.1)'
99
required: true
10+
repository:
11+
description: 'Repository to push the image to (ex: docker.io/sigwindowstools)'
12+
required: false
13+
default: 'docker.io/sigwindowstools'
1014

1115
jobs:
1216
build:
1317
runs-on: ubuntu-latest
1418
steps:
1519
- uses: actions/checkout@v2
20+
21+
- name: Login to DockerHub
22+
if: startsWith(github.event.inputs.repository, 'docker.io')
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ secrets.DOCKER_USERNAME }}
26+
password: ${{ secrets.DOCKER_SECRET }}
27+
1628
- name: Build and push images
1729
run: |
18-
echo "${{ secrets.DOCKER_SECRET }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
19-
pushd ./hostprocess/calico
20-
./build.sh -p ${{ github.event.inputs.proxy_version }}
30+
pushd ./hostprocess/calico
31+
./build.sh -p ${{ github.event.inputs.proxy_version }} -r ${{ github.event.inputs.repository }}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: Sync Kube-Proxy images
3+
4+
on:
5+
schedule:
6+
- cron: '0 0 * * *' # Every day at 00:00 UTC
7+
workflow_dispatch:
8+
inputs:
9+
repository:
10+
description: 'Repository to push the image to (ex: docker.io/sigwindowstools)'
11+
required: false
12+
default: 'docker.io/sigwindowstools'
13+
14+
env:
15+
REPOSITORY: ${{ github.event.inputs.repository || 'docker.io/sigwindowstools' }}
16+
17+
permissions:
18+
actions: write
19+
20+
jobs:
21+
sync:
22+
name: Find and sync missing kube-proxy images
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v6
27+
28+
- name: Login to DockerHub
29+
if: startsWith(env.REPOSITORY, 'docker.io')
30+
uses: docker/login-action@v3
31+
with:
32+
username: ${{ secrets.DOCKER_USERNAME }}
33+
password: ${{ secrets.DOCKER_SECRET }}
34+
35+
- name: Find and trigger builds for missing images
36+
env:
37+
GH_TOKEN: ${{ github.token }}
38+
run: |
39+
set -euo pipefail
40+
41+
REPOSITORY="${{ env.REPOSITORY }}"
42+
MIN_VERSION="1.33"
43+
SUFFIX="-calico-hostprocess"
44+
MISSING=()
45+
46+
# Fetch all kube-proxy tags from registry.k8s.io
47+
echo "Fetching kube-proxy tags from registry.k8s.io..."
48+
TAGS=$(curl -sL "https://registry.k8s.io/v2/kube-proxy/tags/list" | jq -r '.tags[]')
49+
50+
for TAG in $TAGS; do
51+
# Must start with 'v'
52+
[[ "$TAG" != v* ]] && continue
53+
54+
# Skip pre-release tags (contain a hyphen after stripping 'v')
55+
VER="${TAG#v}"
56+
[[ "$VER" == *-* ]] && continue
57+
58+
# Version comparison: must be >= MIN_VERSION
59+
LOWEST=$(printf '%s\n' "$MIN_VERSION" "$VER" | sort -V | head -n1)
60+
[[ "$LOWEST" != "$MIN_VERSION" ]] && continue
61+
62+
IMAGE="${REPOSITORY}/kube-proxy:${TAG}${SUFFIX}"
63+
echo "Checking ${IMAGE} ..."
64+
65+
if docker manifest inspect "$IMAGE" > /dev/null 2>&1; then
66+
echo " exists"
67+
else
68+
echo " missing"
69+
MISSING+=("$TAG")
70+
fi
71+
done
72+
73+
echo ""
74+
echo "=== Summary ==="
75+
if [[ ${#MISSING[@]} -eq 0 ]]; then
76+
echo "All kube-proxy images are up to date."
77+
exit 0
78+
fi
79+
80+
echo "Missing images (${#MISSING[@]}):"
81+
for TAG in "${MISSING[@]}"; do
82+
echo " - ${REPOSITORY}/kube-proxy:${TAG}${SUFFIX}"
83+
done
84+
85+
echo ""
86+
echo "Triggering builds..."
87+
for TAG in "${MISSING[@]}"; do
88+
echo " Dispatching build for ${TAG} -> ${REPOSITORY} ..."
89+
gh workflow run build-kube-proxy-images.yml \
90+
-f proxy_version="$TAG" \
91+
-f repository="$REPOSITORY"
92+
done

0 commit comments

Comments
 (0)