Skip to content

Commit 7777113

Browse files
authored
Merge pull request #18846 from spowelljr/fixAndUpdateCiliumCNI
CNI cilium: Fix and update to v1.15.3
2 parents f339ee8 + acd2085 commit 7777113

File tree

6 files changed

+1386
-781
lines changed

6 files changed

+1386
-781
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "update-cilium-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-cilium-version:
15+
runs-on: ubuntu-20.04
16+
steps:
17+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
18+
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
19+
with:
20+
go-version: ${{env.GO_VERSION}}
21+
- name: Bump cilium version
22+
id: bumpCilium
23+
run: |
24+
echo "OLD_VERSION=$(DEP=cilium make get-dependency-version)" >> "$GITHUB_OUTPUT"
25+
make update-cilium-version
26+
echo "NEW_VERSION=$(DEP=cilium make get-dependency-version)" >> "$GITHUB_OUTPUT"
27+
# 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
28+
echo "changes<<EOF" >> "$GITHUB_OUTPUT"
29+
echo "$(git status --porcelain)" >> "$GITHUB_OUTPUT"
30+
echo "EOF" >> "$GITHUB_OUTPUT"
31+
- name: Create PR
32+
if: ${{ steps.bumpCilium.outputs.changes != '' }}
33+
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e
34+
with:
35+
token: ${{ secrets.MINIKUBE_BOT_PAT }}
36+
commit-message: 'CNI: Update cilium from ${{ steps.bumpCilium.outputs.OLD_VERSION }} to ${{ steps.bumpCilium.outputs.NEW_VERSION }}'
37+
committer: minikube-bot <[email protected]>
38+
author: minikube-bot <[email protected]>
39+
branch: auto_bump_cilium_version
40+
push-to-fork: minikube-bot/minikube
41+
base: master
42+
delete-branch: true
43+
title: 'CNI: Update cilium from ${{ steps.bumpCilium.outputs.OLD_VERSION }} to ${{ steps.bumpCilium.outputs.NEW_VERSION }}'
44+
labels: ok-to-test
45+
body: |
46+
The cilium project released a [new version](https://github.com/cilium/cilium)
47+
48+
This PR was auto-generated by `make update-cilium-version` using [update-cilium-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-cilium-version.yml) CI Workflow.

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,11 @@ update-site-node-version:
12271227
(cd hack/update/site_node_version && \
12281228
go run update_site_node_version.go)
12291229

1230+
.PHONY: update-cilium-version
1231+
update-cilium-version:
1232+
(cd hack/update/cilium_version && \
1233+
go run update_cilium_version.go)
1234+
12301235
.PHONY: get-dependency-verison
12311236
get-dependency-version:
12321237
@(cd hack/update/get_version && \
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
Copyright 2024 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+
"os"
22+
"os/exec"
23+
"path/filepath"
24+
"regexp"
25+
"strings"
26+
"time"
27+
28+
"k8s.io/klog/v2"
29+
"k8s.io/minikube/hack/update"
30+
)
31+
32+
func main() {
33+
if _, err := exec.LookPath("helm"); err != nil {
34+
klog.Fatal("helm not found on system, either install or add to PATH")
35+
}
36+
37+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
38+
defer cancel()
39+
40+
stable, _, _, err := update.GHReleases(ctx, "cilium", "cilium")
41+
if err != nil {
42+
klog.Fatalf("Unable to get stable version: %v", err)
43+
}
44+
version := strings.TrimPrefix(stable.Tag, "v")
45+
46+
// Add the cilium repo to helm
47+
if err := exec.Command("helm", "repo", "add", "cilium", "https://helm.cilium.io/").Run(); err != nil {
48+
klog.Fatal(err)
49+
}
50+
51+
// Generate the cilium YAML
52+
yamlBytes, err := exec.Command("helm", "template", "cilium", "cilium/cilium", "--version", version, "--namespace", "kube-system").Output()
53+
if err != nil {
54+
klog.Fatal(err)
55+
}
56+
yaml := string(yamlBytes)
57+
58+
// Remove the cilium/templates/cilium-ca-secret.yaml section
59+
re := regexp.MustCompile(`# Source: cilium\/templates\/cilium-ca-secret\.yaml(\n.*?)+---\n`)
60+
yaml = re.ReplaceAllString(yaml, "")
61+
62+
// Remove the cilium/templates/hubble/tls-helm/server-secret.yaml section
63+
re = regexp.MustCompile(`# Source: cilium\/templates\/hubble\/tls-helm\/server-secret\.yaml(\n.*?)+---\n`)
64+
yaml = re.ReplaceAllString(yaml, "")
65+
66+
// Replace `cluster-pool-ipv4-cidr` with PodSubnet template
67+
re = regexp.MustCompile(`10\.0\.0\.0\/8`)
68+
yaml = re.ReplaceAllString(yaml, "{{ .PodSubnet }}")
69+
70+
// Change replicas to 1
71+
re = regexp.MustCompile(`replicas:.+`)
72+
yaml = re.ReplaceAllString(yaml, "replicas: 1")
73+
74+
filename := filepath.Join(update.FSRoot, "pkg/minikube/cni/cilium.yaml")
75+
if err := os.WriteFile(filename, []byte(yaml), 0644); err != nil {
76+
klog.Fatal(err)
77+
}
78+
}

hack/update/get_version/get_version.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type dependency struct {
3535
var dependencies = map[string]dependency{
3636
"buildkit": {"deploy/iso/minikube-iso/arch/x86_64/package/buildkit-bin/buildkit-bin.mk", `BUILDKIT_BIN_VERSION = (.*)`},
3737
"calico": {"pkg/minikube/bootstrapper/images/images.go", `calicoVersion = "(.*)"`},
38+
"cilium": {"pkg/minikube/cni/cilium.yaml", `quay.io/cilium/cilium:(.*)@`},
3839
"cloud-spanner": {addonsFile, `cloud-spanner-emulator/emulator:(.*)@`},
3940
"cni-plugins": {"deploy/iso/minikube-iso/arch/x86_64/package/cni-plugins-latest/cni-plugins-latest.mk", `CNI_PLUGINS_LATEST_VERSION = (.*)`},
4041
"containerd": {"deploy/iso/minikube-iso/arch/x86_64/package/containerd-bin/containerd-bin.mk", `CONTAINERD_BIN_VERSION = (.*)`},

0 commit comments

Comments
 (0)