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
48 changes: 48 additions & 0 deletions .github/workflows/update-kubevirt-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "update-kubevirt-version"
on:
workflow_dispatch:
schedule:
# every Saturday at 2:00 Pacific/9:00 UTC
- cron: "0 9 * * 6"
env:
GOPROXY: https://proxy.golang.org
GO_VERSION: '1.25.5'
permissions:
contents: read

jobs:
bump-kubevirt-version:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c
with:
go-version: ${{env.GO_VERSION}}
- name: Bump KubeVirt version
id: bumpKubevirt
run: |
echo "OLD_VERSION=$(DEP=kubevirt make get-dependency-version)" >> "$GITHUB_OUTPUT"
make update-kubevirt-version
echo "NEW_VERSION=$(DEP=kubevirt make get-dependency-version)" >> "$GITHUB_OUTPUT"
# The following is to support multiline with GITHUB_OUTPUT, see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
echo "changes<<EOF" >> "$GITHUB_OUTPUT"
echo "$(git status --porcelain)" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create PR
if: ${{ steps.bumpKubevirt.outputs.changes != '' }}
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725
with:
token: ${{ secrets.MINIKUBE_BOT_PAT }}
commit-message: 'Addon kubevirt: Update KubeVirt version from ${{ steps.bumpKubevirt.outputs.OLD_VERSION }} to ${{ steps.bumpKubevirt.outputs.NEW_VERSION }}'
committer: minikube-bot <minikube-bot@google.com>
author: minikube-bot <minikube-bot@google.com>
branch: auto_bump_kubevirt_version
push-to-fork: minikube-bot/minikube
base: master
delete-branch: true
title: 'Addon kubevirt: Update KubeVirt version from ${{ steps.bumpKubevirt.outputs.OLD_VERSION }} to ${{ steps.bumpKubevirt.outputs.NEW_VERSION }}'
labels: ok-to-test
body: |
The [KubeVirt](https://kubevirt.io/) project released a new version

This PR was auto-generated by `make update-kubevirt-version` using [update-kubevirt-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-kubevirt-version.yml) CI Workflow.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,10 @@ update-crun-version:
update-metrics-server-version:
cd hack && go run update/metrics_server_version/metrics_server_version.go

.PHONY: update-kubevirt-version
update-kubevirt-version:
cd hack && go run update/kubevirt_version/kubevirt_version.go

.PHONY: update-runc-version
update-runc-version:
cd hack && go run update/runc_version/runc_version.go
Expand Down
10 changes: 5 additions & 5 deletions deploy/addons/kubevirt/pod.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ metadata:
data:
uninstall.sh: |
#!/bin/bash
export KUBEVIRT_VERSION="v1.7.0"

kubectl delete kubevirt kubevirt -n kubevirt

kubectl delete -f /manifests/kubevirt-operator.yaml

kubectl delete -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml"
install.sh: |
#!/bin/bash

export KUBEVIRT_VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- - | sort -V | tail -1 | awk -F':' '{print $2}' | sed 's/,//' | xargs)
# To update: check https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt
export KUBEVIRT_VERSION="v1.7.0"
echo "Installing KubeVirt version: $KUBEVIRT_VERSION"

curl -Ls "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml" -o /manifests/kubevirt-operator.yaml
kubectl create -f /manifests/kubevirt-operator.yaml
kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml"

HARDWARE_EMULATION=$(grep -E 'svm|vmx' /proc/cpuinfo)
if [ -z "$HARDWARE_EMULATION" ]; then
Expand Down
1 change: 1 addition & 0 deletions hack/update/get_version/get_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var dependencies = map[string]dependency{
"kube-registry-proxy": {addonsFile, `"k8s-minikube/kube-registry-proxy:(.*)@`},
"kube-vip": {"pkg/minikube/cluster/ha/kube-vip/kube-vip.go", `image: ghcr.io/kube-vip/kube-vip:(.*)`},
"kubectl": {addonsFile, `bitnami/kubectl:(.*)@`},
"kubevirt": {"deploy/addons/kubevirt/pod.yaml.tmpl", `KUBEVIRT_VERSION="(.*)"`},
"metrics-server": {addonsFile, `metrics-server/metrics-server:(.*)@`},
"nerdctl": {"deploy/kicbase/Dockerfile", `NERDCTL_VERSION="(.*)"`},
"nerdctld": {"deploy/kicbase/Dockerfile", `NERDCTLD_VERSION="(.*)"`},
Expand Down
86 changes: 86 additions & 0 deletions hack/update/kubevirt_version/kubevirt_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adilwiser thank you for this fix please also add an github action simmilar to this so it bumps it automatically
https://github.com/kubernetes/minikube/blob/master/.github/workflows/update-yakd-version.yml

and please verify manually that updater works

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing me in that direction! I'll address it asap!

Copyright 2024 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"context"
"io"
"net/http"
"strings"
"time"

"k8s.io/klog/v2"

"k8s.io/minikube/hack/update"
)

const (
cxTimeout = 5 * time.Minute
// KubeVirt publishes stable version at this URL
stableVersionURL = "https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt"
)

var schema = map[string]update.Item{
"deploy/addons/kubevirt/pod.yaml.tmpl": {
Replace: map[string]string{
`KUBEVIRT_VERSION="v.*"`: `KUBEVIRT_VERSION="{{.Version}}"`,
},
},
}

// Data holds the version information for templating
type Data struct {
Version string
}

func main() {
ctx, cancel := context.WithTimeout(context.Background(), cxTimeout)
defer cancel()

stable, err := getStableKubeVirtVersion(ctx)
if err != nil {
klog.Fatalf("Unable to get KubeVirt stable version: %v", err)
}

data := Data{Version: stable}
klog.Infof("KubeVirt stable version: %s", data.Version)

if err := update.Apply(schema, data); err != nil {
klog.Fatalf("unable to apply update: %v", err)
}
}

// getStableKubeVirtVersion fetches the stable KubeVirt version from the official release endpoint
func getStableKubeVirtVersion(ctx context.Context) (string, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, stableVersionURL, nil)
if err != nil {
return "", err
}

resp, err := http.DefaultClient.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}

return strings.TrimSpace(string(body)), nil
}
1 change: 0 additions & 1 deletion hack/update/update_all/update_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var (
"istio_operator_version": true, // till this is fixed https://github.com/istio/istio/issues/57185
"kicbase_version": true, // This one is not related to auto updating, this is a tool used by kicbae_auto_build
"preload_version": true, // This is an internal tool to bump the preload version, not a component update
"kubectl_version": true, // used by kubevirt addon, disabled until we find a replacement for bitnami/kubectl image
}
)

Expand Down