Skip to content

Commit 3e10cfc

Browse files
ComradeProgrammermedyagh
authored andcommitted
addon: add auto updater for volcano addon
1 parent d67dfb3 commit 3e10cfc

File tree

6 files changed

+140
-0
lines changed

6 files changed

+140
-0
lines changed

Diff for: .github/workflows/update-volcano-version.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "update-volcano-version"
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
# every Monday at around 3 am pacific/10 am UTC
6+
- cron: "0 10 * * 1"
7+
env:
8+
GOPROXY: https://proxy.golang.org
9+
GO_VERSION: '1.22.1'
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
bump-volcano-version:
15+
runs-on: ubuntu-20.04
16+
steps:
17+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
18+
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
19+
with:
20+
go-version: ${{env.GO_VERSION}}
21+
cache-dependency-path: ./go.sum
22+
- name: Bump volcano version
23+
id: bumpVolcano
24+
run: |
25+
echo "OLD_VERSION=$(DEP=volcano make get-dependency-version)" >> "$GITHUB_OUTPUT"
26+
make update-volcano-version
27+
echo "NEW_VERSION=$(DEP=volcano make get-dependency-version)" >> "$GITHUB_OUTPUT"
28+
# 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
29+
echo "changes<<EOF" >> "$GITHUB_OUTPUT"
30+
echo "$(git status --porcelain)" >> "$GITHUB_OUTPUT"
31+
echo "EOF" >> "$GITHUB_OUTPUT"
32+
- name: Create PR
33+
if: ${{ steps.bumpVolcano.outputs.changes != '' }}
34+
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e
35+
with:
36+
token: ${{ secrets.MINIKUBE_BOT_PAT }}
37+
commit-message: 'Addon Volcano: Update volcano images from ${{ steps.bumpVolcano.outputs.OLD_VERSION }} to ${{ steps.bumpVolcano.outputs.NEW_VERSION }}'
38+
committer: minikube-bot <[email protected]>
39+
author: minikube-bot <[email protected]>
40+
branch: auto_bump_volcano_version
41+
push-to-fork: minikube-bot/minikube
42+
base: master
43+
delete-branch: true
44+
title: 'Addon Volcano: Update volcano images from ${{ steps.bumpVolcano.outputs.OLD_VERSION }} to ${{ steps.bumpVolcano.outputs.NEW_VERSION }}'
45+
labels: ok-to-test
46+
body: |
47+
The [Volcano](https://github.com/volcano-sh/volcano) project made a new release
48+
49+
This PR was auto-generated by `make update-volcano-version` using [update-volcano-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-volcano-version.yml) CI Workflow.

Diff for: Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,11 @@ update-registry-version:
11971197
(cd hack/update/registry_version && \
11981198
go run update_registry_version.go)
11991199

1200+
.PHONY: update-volcano-version
1201+
update-volcano-version:
1202+
(cd hack/update/volcano_version && \
1203+
go run update_volcano_version.go)
1204+
12001205
.PHONY: update-kong-version
12011206
update-kong-version:
12021207
(cd hack/update/kong_version && \

Diff for: hack/update/get_version/get_version.go

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var dependencies = map[string]dependency{
5959
"istio-operator": {addonsFile, `istio/operator:(.*)@`},
6060
"kindnetd": {"pkg/minikube/bootstrapper/images/images.go", `kindnetd:(.*)"`},
6161
"kong": {addonsFile, `kong:(.*)@`},
62+
"volcano": {addonsFile, `volcanosh/vc-webhook-manager:(.*)@`},
6263
"kong-ingress-controller": {addonsFile, `kong/kubernetes-ingress-controller:(.*)@`},
6364
"kubectl": {addonsFile, `bitnami/kubectl:(.*)@`},
6465
"metrics-server": {addonsFile, `metrics-server/metrics-server:(.*)@`},
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"context"
21+
"fmt"
22+
"time"
23+
24+
"k8s.io/klog/v2"
25+
"k8s.io/minikube/hack/update"
26+
)
27+
28+
var schema = map[string]update.Item{
29+
"pkg/minikube/assets/addons.go": {
30+
Replace: map[string]string{
31+
`vc-webhook-manager:.*`: `vc-webhook-manager:{{.Version}}@{{.SHAWebhookManager}}",`,
32+
`vc-controller-manager:.*`: `vc-controller-manager:{{.Version}}@{{.SHAControllerManager}}",`,
33+
`vc-scheduler:.*`: `vc-scheduler:{{.Version}}@{{.SHAScheduler}}",`,
34+
},
35+
},
36+
}
37+
38+
type Data struct {
39+
Version string
40+
SHAWebhookManager string
41+
SHAControllerManager string
42+
SHAScheduler string
43+
}
44+
45+
func main() {
46+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
47+
defer cancel()
48+
49+
stable, _, _, err := update.GHReleases(ctx, "volcano-sh", "volcano")
50+
if err != nil {
51+
klog.Fatalf("Unable to get stable version: %v", err)
52+
}
53+
version := stable.Tag
54+
shaWebhookManager, err := update.GetImageSHA(fmt.Sprintf("docker.io/volcanosh/vc-webhook-manager:%s", version))
55+
if err != nil {
56+
klog.Fatalf("failed to get manifest digest for docker.io/volcanosh/vc-webhook-manager: %v", err)
57+
}
58+
59+
shaControllerManager, err := update.GetImageSHA(fmt.Sprintf("docker.io/volcanosh/vc-controller-manager:%s", version))
60+
if err != nil {
61+
klog.Fatalf("failed to get manifest digest for docker.io/volcanosh/vc-controller-manager: %v", err)
62+
}
63+
64+
shaScheduler, err := update.GetImageSHA(fmt.Sprintf("docker.io/volcanosh/vc-scheduler:%s", version))
65+
if err != nil {
66+
klog.Fatalf("failed to get manifest digest for docker.io/volcanosh/vc-scheduler: %v", err)
67+
}
68+
69+
data := Data{
70+
Version: version,
71+
SHAWebhookManager: shaWebhookManager,
72+
SHAControllerManager: shaControllerManager,
73+
SHAScheduler: shaScheduler,
74+
}
75+
76+
update.Apply(schema, data)
77+
}

Diff for: pkg/addons/addons.go

+5
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ func addonSpecificChecks(cc *config.ClusterConfig, name string, enable bool, run
356356
}
357357
}
358358

359+
// we cannot use volcano for crio
360+
if name == "volcano" && cc.KubernetesConfig.ContainerRuntime == constants.CRIO && enable {
361+
return false, fmt.Errorf("volcano addon does not support crio")
362+
}
363+
359364
return false, nil
360365
}
361366

Diff for: test/integration/addons_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,9 @@ func validateCloudSpannerAddon(ctx context.Context, t *testing.T, profile string
867867
// validateVolcanoAddon tests the Volcano addon, makes sure the Volcano is installed into cluster.
868868
func validateVolcanoAddon(ctx context.Context, t *testing.T, profile string) {
869869
defer PostMortemLogs(t, profile)
870+
if ContainerRuntime() == "crio" {
871+
t.Skipf("skipping: crio not supported")
872+
}
870873

871874
volcanoNamespace := "volcano-system"
872875

0 commit comments

Comments
 (0)