Skip to content

Commit 74eba4c

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

File tree

2 files changed

+332
-1
lines changed

2 files changed

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

0 commit comments

Comments
 (0)