Skip to content

Commit a0f4060

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

File tree

2 files changed

+326
-1
lines changed

2 files changed

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

0 commit comments

Comments
 (0)