Skip to content

Commit 2de6305

Browse files
committed
Update README and add an example of chart bumping
Signed-off-by: Jian Wang <[email protected]>
1 parent 33d258c commit 2de6305

File tree

2 files changed

+329
-1
lines changed

2 files changed

+329
-1
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Harvester Charts
2-
![Release Charts](https://github.com/harvester/charts/workflows/Release%20Charts/badge.svg)
32

43
## Prerequisites
54
- Helm 3.x
@@ -17,3 +16,6 @@ Once pushed, GitHub Actions will look for any changes to charts in the `charts/`
1716

1817
Note that changes should only be synced to this repository when ready for a new release. GitHub Actions will fail if making changes to the charts in this repository directly, as Chart Releaser will not attempt to override old chart releases.
1918

19+
## Example
20+
21+
Refer the [release a chart and bump to upstream](./release-a-chart-and-bump-to-upstream.md) for more details.
+326
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
# Release a New Chart and Bump it to Upstream
2+
3+
## Release a New Chart on Harvester Chart Repo
4+
5+
This document will demonstrate how to release a new harvester-cloud-provider chart version, and bump the new version to upstream.
6+
7+
### Change an Existing Chart
8+
9+
e.g. https://github.com/harvester/charts/pull/229
10+
11+
merge to `master` branch
12+
13+
Note the chart version on `master` is `stable`, e.g. https://github.com/harvester/charts/blob/9cd25bd54370e38b3d2a1731c317c418d079b8ff/charts/harvester-cloud-provider/Chart.yaml#L21, it keeps as `version: 0.0.0-dev`
14+
15+
### Release a New Version
16+
17+
Cherry-pick all changes against the chart on `master` branch, and add another commit to amend the `version` field on `Chart.yaml`
18+
19+
After the PR to `release` branch is merged, a new chart version is released automatically.
20+
21+
e.g. https://github.com/harvester/charts/pull/230
22+
23+
e.g. https://github.com/harvester/charts/releases/tag/harvester-cloud-provider-0.2.4
24+
25+
The chart like `harvester-cloud-provider` and `harvester-csi-driver` also need to be bumped to upstream RKE2 and Rancher. The following sections describe the details.
26+
27+
## Bump the Chart to `RKE2`
28+
29+
### Update `rancher/rke2-charts`
30+
31+
Point to the new release on Harvester chart repo.
32+
33+
https://github.com/rancher/rke2-charts/blob/main-source/packages/harvester-cloud-provider/package.yaml
34+
35+
e.g. https://github.com/rancher/rke2-charts/pull/454
36+
37+
### Update `rancher/rke2`
38+
39+
Point to the new chart version, then `RKE2` will use the new chart version as the default value.
40+
41+
https://github.com/rancher/rke2/blob/master/charts/chart_versions.yaml
42+
43+
e.g. https://github.com/rancher/rke2/pull/5980
44+
45+
:::note
46+
47+
Add PR to each active `rancher/rke2` branch.
48+
49+
:::
50+
51+
## Bump the Chart to `Rancher`
52+
53+
### Bump the chart to `rancher/charts`
54+
55+
Rancher charts are managed in a more complex way. First, read the document on this repo like https://github.com/rancher/charts/blob/dev-v2.9/README.md, https://github.com/rancher/charts/blob/dev-v2.9/docs/developing.md.
56+
57+
We need the help of those two paths to step-by-step generate the target files.
58+
59+
```
60+
// used to download chart file in `make prepare`
61+
packages/harvester/harvester-cloud-provider/charts/
62+
63+
// used to put the generated patch files
64+
packages/harvester/harvester-cloud-provider/generated-changes/
65+
66+
```
67+
68+
Example: https://github.com/rancher/charts/pull/3234
69+
70+
:::note
71+
72+
Add PR to each active `rancher/charts` branch.
73+
74+
:::
75+
76+
#### Update the package.yaml file
77+
78+
Update the `url` and `version` fields.
79+
80+
```
81+
diff --git a/packages/harvester/harvester-cloud-provider/package.yaml b/packages/harvester/harvester-cloud-provider/package.yaml
82+
index 7e86c3d2..5485f225 100644
83+
--- a/packages/harvester/harvester-cloud-provider/package.yaml
84+
+++ b/packages/harvester/harvester-cloud-provider/package.yaml
85+
@@ -1,3 +1,3 @@
86+
-url: https://github.com/harvester/charts/releases/download/harvester-cloud-provider-0.1.14/harvester-cloud-provider-0.1.14.tgz
87+
+url: https://github.com/harvester/charts/releases/download/harvester-cloud-provider-0.2.2/harvester-cloud-provider-0.2.2.tgz
88+
version: 103.0.0
89+
doNotRelease: false
90+
```
91+
92+
:::note
93+
94+
The Rancher version `103.0.0` needs to increase to a next version like `103.0.1` if `103.0.0` has been used, otherwise, the `index.yaml` will not be updated.
95+
96+
:::
97+
98+
99+
#### (Optional) Prepare the dependency file
100+
101+
Prepare the dependency file if it comes for the first time.
102+
103+
```
104+
+++ b/packages/harvester/harvester-cloud-provider/generated-changes/dependencies/kube-vip/dependency.yaml
105+
@@ -0,0 +1,3 @@
106+
+workingDir: ""
107+
+url: https://github.com/harvester/charts/releases/download/harvester-cloud-provider-0.2.2/harvester-cloud-provider-0.2.2.tgz
108+
+subdirectory: dependency_charts/kube-vip
109+
```
110+
111+
#### Make prepare
112+
113+
Make prepare will pull the source chart into path like `packages/harvester/harvester-cloud-provider`
114+
115+
```
116+
$ export PACKAGE=harvester/harvester-cloud-provider
117+
118+
$ make prepare
119+
120+
/go/src/github.com/w13915984028/rancher-charts$ make prepare
121+
INFO[0000] Pulling https://github.com/harvester/charts/releases/download/harvester-cloud-provider-0.2.2/harvester-cloud-provider-0.2.2.tgz from upstream into charts
122+
INFO[0000] Loading dependencies for chart
123+
INFO[0000] found chart options for kube-vip in generated-changes/dependencies/kube-vip/dependency.yaml
124+
INFO[0000] Found chart options for kube-vip in generated-changes/dependencies/kube-vip/dependency.yaml
125+
INFO[0000] Pulling https://github.com/harvester/charts/releases/download/harvester-cloud-provider-0.2.2/harvester-cloud-provider-0.2.2.tgz[path=dependency_charts/kube-vip] from upstream into charts
126+
INFO[0000] Updating chart metadata with dependencies
127+
WARN[0000] Detected 'apiVersion:v2' within Chart.yaml; these types of charts require additional testing
128+
INFO[0000] Applying changes from generated-changes
129+
INFO[0000] Applying: generated-changes/patch/Chart.yaml.patch
130+
ERRO[0000]
131+
patching file Chart.yaml
132+
Hunk #1 FAILED at 1.
133+
1 out of 1 hunk FAILED -- saving rejects to file Chart.yaml.rej
134+
FATA[0000] encountered error while preparing main chart: encountered error while trying to apply changes to charts: unable to generate patch with error: exit status 1
135+
make: *** [Makefile:17: prepare] Error 1
136+
```
137+
138+
::: note
139+
140+
If the above error is shown, simply remove the file `./packages/harvester/harvester-cloud-provider/generated-changes/patch/Chart.yaml.patch`, it means: the previous patch file has conflict, we need to generate a new one.
141+
142+
:::
143+
144+
#### Generate the patch file manually
145+
146+
Prepare the important patch file: `generated-changes/patch/Chart.yaml.patch`
147+
148+
:::note
149+
150+
Remove the origin `Chart.yaml.patch` first. Otherwise it may mislead us.
151+
152+
Make a copy of `Chart.yaml` and change it. Then use `diff` to get the new `Chart.yaml.patch`.
153+
154+
:::
155+
156+
```
157+
/go/src/github.com/w13915984028/rancher-charts/packages/harvester/harvester-cloud-provider/charts$ diff Chart.yaml Chart1.yaml -u > ../generated-changes/patch/Chart.yaml.patch
158+
--- Chart.yaml 2024-01-08 20:33:08.893433595 +0100
159+
+++ Chart1.yaml 2024-01-08 21:07:53.378778026 +0100
160+
@@ -4,7 +4,7 @@
161+
catalog.cattle.io/kube-version: '>= 1.23.0-0 < 1.27.0-0'
162+
catalog.cattle.io/namespace: kube-system
163+
catalog.cattle.io/os: linux
164+
- catalog.cattle.io/rancher-version: '>= 2.7.0-0 < 2.8.0-0'
165+
+ catalog.cattle.io/rancher-version: '>= 2.9.0-0 < 2.10.0-0'
166+
catalog.cattle.io/release-name: harvester-cloud-provider
167+
catalog.cattle.io/ui-component: harvester-cloud-provider
168+
catalog.cattle.io/upstream-version: 0.2.0
169+
170+
manually change it to:
171+
172+
--- charts-original/Chart.yaml
173+
+++ charts/Chart.yaml
174+
@@ -4,7 +4,7 @@
175+
catalog.cattle.io/kube-version: '>= 1.23.0-0 < 1.27.0-0'
176+
catalog.cattle.io/namespace: kube-system
177+
catalog.cattle.io/os: linux
178+
- catalog.cattle.io/rancher-version: '>= 2.7.0-0 < 2.8.0-0'
179+
+ catalog.cattle.io/rancher-version: '>= 2.9.0-0 < 2.10.0-0'
180+
catalog.cattle.io/release-name: harvester-cloud-provider
181+
catalog.cattle.io/ui-component: harvester-cloud-provider
182+
catalog.cattle.io/upstream-version: 0.2.0
183+
```
184+
185+
#### (Optional) Generate special patch file manually
186+
187+
When running `make check-images` you may encounter such error:
188+
189+
```
190+
time="2023-11-03T21:56:40Z" level=fatal msg="failed to generate namespace and repository for image: ghcr.io/kube-vip/kube-vip"
191+
make: *** [Makefile:17: check-images] Error 1
192+
```
193+
194+
It is due to the make charts does not allow image format like `ghcr.io/kube-vip/kube-vip`, only one `/` can exist
195+
196+
In `harvester-cloud-provider`, there are:
197+
198+
```
199+
charts/dependency_charts/kube-vip/values.yaml: repository: ghcr.io/kube-vip/kube-vip
200+
charts/charts/kube-vip/values.yaml: repository: ghcr.io/kube-vip/kube-vip
201+
```
202+
203+
Make a copy of the `dependency_charts/kube-vip/values.yaml` and modify it, finally generate a patch file like:
204+
205+
```
206+
$ diff -Naur values.yaml values1.yaml > values.yaml.patch
207+
208+
--- values.yaml 2023-11-03 22:53:06.468672017 +0100
209+
+++ values1.yaml 2023-11-17 21:14:04.573425541 +0100
210+
@@ -3,10 +3,10 @@
211+
# Declare variables to be passed into your templates.
212+
213+
image:
214+
- repository: ghcr.io/kube-vip/kube-vip
215+
+ repository: rancher/mirrored-kube-vip-kube-vip-iptables
216+
pullPolicy: IfNotPresent
217+
# Overrides the image tag whose default is the chart appVersion.
218+
- tag: "v0.4.1"
219+
+ tag: "v0.6.0"
220+
221+
config:
222+
address: ""
223+
```
224+
225+
Edit the file to change file name and remove timestamp, finally `git diff` will show it as:
226+
227+
```
228+
+++ b/packages/harvester/harvester-cloud-provider/generated-changes/patch/dependency_charts/kube-vip/values.yaml.patch
229+
@@ -0,0 +1,15 @@
230+
+--- charts-original/dependency_charts/kube-vip/values.yaml
231+
++++ charts/dependency_charts/kube-vip/values.yaml
232+
+@@ -3,10 +3,10 @@
233+
+ # Declare variables to be passed into your templates.
234+
+
235+
+ image:
236+
+- repository: ghcr.io/kube-vip/kube-vip
237+
++ repository: rancher/mirrored-kube-vip-kube-vip-iptables
238+
+ pullPolicy: IfNotPresent
239+
+ # Overrides the image tag whose default is the chart appVersion.
240+
+- tag: "v0.4.1"
241+
++ tag: "v0.6.0"
242+
+
243+
+ config:
244+
+ address: ""
245+
```
246+
247+
Same procedure against `charts/kube-vip/values.yaml` and get the generated `values.yaml.patch`.
248+
249+
```
250+
--- charts-original/charts/kube-vip/values.yaml
251+
+++ charts/charts/kube-vip/values.yaml
252+
@@ -3,10 +3,10 @@
253+
# Declare variables to be passed into your templates.
254+
255+
image:
256+
- repository: ghcr.io/kube-vip/kube-vip
257+
+ repository: rancher/mirrored-kube-vip-kube-vip-iptables
258+
pullPolicy: IfNotPresent
259+
# Overrides the image tag whose default is the chart appVersion.
260+
- tag: "v0.4.1"
261+
+ tag: "v0.6.0"
262+
263+
config:
264+
address: ""
265+
```
266+
267+
#### Make
268+
269+
The whole command list is:
270+
271+
```
272+
$ export PACKAGE=harvester/harvester-cloud-provider
273+
274+
$ make prepare
275+
276+
$ make patch
277+
278+
$ make clean
279+
280+
$ make charts
281+
```
282+
When no error happens, commit the changes.
283+
284+
#### Make validate
285+
286+
Such error may happen:
287+
288+
```
289+
INFO[0178] harvester-cloud-provider/103.0.0+up0.2.2 is untracked
290+
ERRO[0181] The following new assets have been introduced: map[harvester-cloud-provider:[103.0.0+up0.2.2]]
291+
ERRO[0181] The following released assets have been removed: map[]
292+
ERRO[0181] The following released assets have been modified: map[]
293+
ERRO[0181] If this was intentional, to allow validation to pass, these charts must be added to the release.yaml.
294+
INFO[0181] Dumping release.yaml tracking changes that have been introduced
295+
```
296+
297+
Update the release.yaml, commit.
298+
299+
```
300+
$ diff --git a/release.yaml b/release.yaml
301+
index 422c128f..7ff5a50c 100644
302+
--- a/release.yaml
303+
+++ b/release.yaml
304+
@@ -26,6 +26,7 @@ fleet-crd:
305+
- 103.1.0+up0.9.0-rc.5
306+
harvester-cloud-provider:
307+
- 103.0.0+up0.1.14
308+
+ - 103.0.0+up0.2.2
309+
harvester-csi-driver:
310+
- 103.0.0+up0.1.16
311+
312+
```
313+
314+
`make validate` again.
315+
316+
```
317+
...
318+
INFO[0188] index.yaml is up-to-date
319+
INFO[0188] Doing a final check to ensure Git is clean
320+
INFO[0190] Successfully validated current repository!
321+
322+
```
323+
324+
#### Always check
325+
326+
Check again to make sure all the requirements from `rancher/charts` are met.

0 commit comments

Comments
 (0)