Skip to content

Commit

Permalink
addon: add auto updater for volcano addon
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeProgrammer committed Apr 22, 2024
1 parent 5593c1b commit eddd193
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/update-volcano-version.yml
@@ -0,0 +1,49 @@
name: "update-volcano-version"
on:
workflow_dispatch:
schedule:
# every Monday at around 3 am pacific/10 am UTC
- cron: "0 10 * * 1"
env:
GOPROXY: https://proxy.golang.org
GO_VERSION: '1.22.1'
permissions:
contents: read

jobs:
bump-volcano-version:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: ${{env.GO_VERSION}}
cache-dependency-path: ./go.sum
- name: Bump volcano version
id: bumpVolcano
run: |
echo "OLD_VERSION=$(DEP=volcano make get-dependency-version)" >> "$GITHUB_OUTPUT"
make update-volcano-version
echo "NEW_VERSION=$(DEP=volcano 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.bumpVolcano.outputs.changes != '' }}
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e
with:
token: ${{ secrets.MINIKUBE_BOT_PAT }}
commit-message: 'Addon Volcano: Update volcano images from ${{ steps.bumpVolcano.outputs.OLD_VERSION }} to ${{ steps.bumpVolcano.outputs.NEW_VERSION }}'
committer: minikube-bot <minikube-bot@google.com>
author: minikube-bot <minikube-bot@google.com>
branch: auto_bump_volcano_version
push-to-fork: minikube-bot/minikube
base: master
delete-branch: true
title: 'Addon Volcano: Update volcano images from ${{ steps.bumpVolcano.outputs.OLD_VERSION }} to ${{ steps.bumpVolcano.outputs.NEW_VERSION }}'
labels: ok-to-test
body: |
The [Volcano](https://github.com/volcano-sh/volcano) project made a new release
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.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -1188,6 +1188,11 @@ update-registry-version:
(cd hack/update/registry_version && \
go run update_registry_version.go)

.PHONY: update-volcano-version
update-volcano-version:
(cd hack/update/volcano_version && \
go run update_volcano_version.go)

.PHONY: update-kong-version
update-kong-version:
(cd hack/update/kong_version && \
Expand Down
1 change: 1 addition & 0 deletions hack/update/get_version/get_version.go
Expand Up @@ -58,6 +58,7 @@ var dependencies = map[string]dependency{
"istio-operator": {addonsFile, `istio/operator:(.*)@`},
"kindnetd": {"pkg/minikube/bootstrapper/images/images.go", `kindnetd:(.*)"`},
"kong": {addonsFile, `kong:(.*)@`},
"volcano": {addonsFile, `volcanosh/vc-webhook-manager:(.*)@`},
"kong-ingress-controller": {addonsFile, `kong/kubernetes-ingress-controller:(.*)@`},
"kubectl": {addonsFile, `bitnami/kubectl:(.*)@`},
"metrics-server": {addonsFile, `metrics-server/metrics-server:(.*)@`},
Expand Down
77 changes: 77 additions & 0 deletions hack/update/volcano_version/update_volcano_version.go
@@ -0,0 +1,77 @@
/*
Copyright 2023 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"
"fmt"
"time"

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

var schema = map[string]update.Item{
"pkg/minikube/assets/addons.go": {
Replace: map[string]string{
`vc-webhook-manager:.*`: `vc-webhook-manager:{{.Version}}@{{.SHAWebhookManager}}",`,
`vc-controller-manager:.*`: `vc-controller-manager:{{.Version}}@{{.SHAControllerManager}}",`,
`vc-scheduler:.*`: `vc-scheduler:{{.Version}}@{{.SHAScheduler}}",`,
},
},
}

type Data struct {
Version string
SHAWebhookManager string
SHAControllerManager string
SHAScheduler string
}

func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

stable, _, _, err := update.GHReleases(ctx, "volcano-sh", "volcano")
if err != nil {
klog.Fatalf("Unable to get stable version: %v", err)
}
version := stable.Tag
shaWebhookManager, err := update.GetImageSHA(fmt.Sprintf("docker.io/volcanosh/vc-webhook-manager:%s", version))
if err != nil {
klog.Fatalf("failed to get manifest digest for docker.io/volcanosh/vc-webhook-manager: %v", err)
}

shaControllerManager, err := update.GetImageSHA(fmt.Sprintf("docker.io/volcanosh/vc-controller-manager:%s", version))
if err != nil {
klog.Fatalf("failed to get manifest digest for docker.io/volcanosh/vc-controller-manager: %v", err)
}

shaScheduler, err := update.GetImageSHA(fmt.Sprintf("docker.io/volcanosh/vc-scheduler:%s", version))
if err != nil {
klog.Fatalf("failed to get manifest digest for docker.io/volcanosh/vc-scheduler: %v", err)
}

data := Data{
Version: version,
SHAWebhookManager: shaWebhookManager,
SHAControllerManager: shaControllerManager,
SHAScheduler: shaScheduler,
}

update.Apply(schema, data)
}
5 changes: 5 additions & 0 deletions pkg/addons/addons.go
Expand Up @@ -356,6 +356,11 @@ func addonSpecificChecks(cc *config.ClusterConfig, name string, enable bool, run
}
}

// we cannot use volcano for crio
if name == "volcano" && cc.KubernetesConfig.ContainerRuntime == constants.CRIO && enable {
return false, fmt.Errorf("volcano addon does not support crio")
}

return false, nil
}

Expand Down
3 changes: 3 additions & 0 deletions test/integration/addons_test.go
Expand Up @@ -867,6 +867,9 @@ func validateCloudSpannerAddon(ctx context.Context, t *testing.T, profile string
// validateVolcanoAddon tests the Volcano addon, makes sure the Volcano is installed into cluster.
func validateVolcanoAddon(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
if(ContainerRuntime() == "crio"){
t.Skipf("skipping: crio not supported")
}

volcanoNamespace := "volcano-system"

Expand Down

0 comments on commit eddd193

Please sign in to comment.