Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm: add arkade chart bump to bump chart versions #1024

Closed
wants to merge 3 commits into from

Conversation

aryan9600
Copy link
Contributor

@aryan9600 aryan9600 commented Jan 22, 2024

Description

Add a new command arkade chart bump --dir ./chart to bump the minor of a Helm chart version. By default, the changes are written to stdout. Specifying the --write flag writes the changes to the respective file.
Specifying the flag --check-for-value-updates skips bumping the chart version if the adjacent values file does not have any changes according to the Git.

Motivation and Context

How Has This Been Tested?

Built the CLI manually and tested various scenarios:

  • Relative paths:
# Single chart
❯ ../../arkade/arkade chart bump --dir ./charts/flagger
charts/flagger/Chart.yaml 1.35.0 => 1.36.0

# Multiple charts
❯ ../../arkade/arkade chart bump --dir ./charts --recursive
Found 4 charts
charts/flagger/Chart.yaml 1.35.0 => 1.36.0
charts/grafana/Chart.yaml 1.7.0 => 1.8.0
charts/loadtester/Chart.yaml 0.30.0 => 0.31.0
charts/podinfo/Chart.yaml 6.1.3 => 6.2.0

# Write enabled
❯ ../../arkade/arkade chart bump --dir ./charts --recursive --write
Found 4 charts
charts/flagger/Chart.yaml 1.35.0 => 1.36.0
charts/grafana/Chart.yaml 1.7.0 => 1.8.0
charts/loadtester/Chart.yaml 0.30.0 => 0.31.0
charts/podinfo/Chart.yaml 6.1.3 => 6.2.0

❯ git --no-pager diff
diff --git a/charts/flagger/Chart.yaml b/charts/flagger/Chart.yaml
index 6df33502..31ccf27a 100644
--- a/charts/flagger/Chart.yaml
+++ b/charts/flagger/Chart.yaml
@@ -1,6 +1,6 @@
 apiVersion: v1
 name: flagger
-version: 1.35.0
+version: 1.36.0
 appVersion: 1.35.0
 kubeVersion: ">=1.19.0-0"
 engine: gotpl
# ...omitted for brevity
  • Absolute paths:
# Single chart
❯ ./arkade chart bump --dir ~/Development/fluxcd/flagger/charts/flagger
/Users/sanskarjaiswal/Development/fluxcd/flagger/charts/flagger/Chart.yaml 1.36.0 => 1.37.0

# Multiple charts
❯ ./arkade chart bump --dir ~/Development/fluxcd/flagger/charts --recursive
Found 4 charts
/Users/sanskarjaiswal/Development/fluxcd/flagger/charts/flagger/Chart.yaml 1.36.0 => 1.37.0
/Users/sanskarjaiswal/Development/fluxcd/flagger/charts/grafana/Chart.yaml 1.8.0 => 1.9.0
/Users/sanskarjaiswal/Development/fluxcd/flagger/charts/loadtester/Chart.yaml 0.31.0 => 0.32.0
/Users/sanskarjaiswal/Development/fluxcd/flagger/charts/podinfo/Chart.yaml 6.2.0 => 6.3.0

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Documentation

  • I have updated the list of tools in README.md if (required) with ./arkade get --format markdown
  • I have updated the list of apps in README.md if (required) with ./arkade install --help

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have tested this on arm, or have added code to prevent deployment

@alexellis
Copy link
Owner

alexellis commented Jan 22, 2024

Thanks for the PR and the detailed test output.

I'm thinking a bit more about workflow.

What if only one of the charts has changes pending from the upgrade command?

I.e. the Makefile in openfaas/faas-netes has a make upgrade-charts target, and possibly only one or two charts will need a bump due to changes in image versions.

Maybe simulate that? https://github.com/openfaas/faas-netes

Back off a version of "image" in two charts, then run the make upgrade-charts followed by thinking about how we could only bump the adjacent images?

And what if someone ran make upgrade charts twice, we wouldn't want to bump the version twice etc.

Other charts have a single values.yaml like - https://github.com/inlets/inlets-operator/blob/master/chart/inlets-operator/values.yaml#L44

Alex

@alexellis
Copy link
Owner

To simplify things, we could assume the workflow of:

make upgrade-charts

make bump-charts

The first uses the existing command, the second uses the new one. The maintainer won't run the second command twice in a row, otherwise they'll get a double bump. The first command is still re-runnable.

We could skip --recursive in this PR, and if we want to add it later, make sure it's in both commands so they are consistent.

@aryan9600
Copy link
Contributor Author

Is the intention with the new workflow to only bump charts when the image in the chart gets updated? Or do we want to bump the chart version regardless of what action make upgrade-charts resulted in?

@alexellis
Copy link
Owner

alexellis commented Jan 22, 2024

Is the intention with the new workflow to only bump charts when the image in the chart gets updated? Or do we want to bump the chart version regardless of what action make upgrade-charts resulted in?

Sorry that I was unclear. Can you walk through the example I shared?

  1. Maintainer knows there are new releases for 1 or more openfaas charts
  2. He runs make upgrade-charts - this re-writes the file, but perhaps not all images are published, so he has to run it again (we don't want to bump the chart twice as a combined option)
  3. He runs make bump-charts

Suggest one or more ways that you can determine if a values.yaml has changed, and then only bump its adjacent Chart.yaml if that's the case.

upgrade-charts:
	@echo Upgrading images for all helm charts && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/openfaas/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/kafka-connector/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/cron-connector/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/nats-connector/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/mqtt-connector/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/pro-builder/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/sqs-connector/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/postgres-connector/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/queue-worker/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/sns-connector/values.yaml && \
	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/federated-gateway/values.yaml

So the same would be repeated i.e.

bump-charts
	arkade chart bump --verbose=$(VERBOSE) -w -f ./chart/federated-gateway/values.yaml && \
	arkade chart bump --verbose=$(VERBOSE) -w -f ./chart/kafka-connector/values.yaml && \
...

@aryan9600
Copy link
Contributor Author

If we only want to bump the version in Chart.yaml if we have changes in the adjacent values.yaml, I guess we can modify arkade chart bump to use Git and figure out whether there actually are any changes in the values.yaml file.
But this does introduce a prerequisite for Git to be installed on the system and for the working directory to be a Git repository. Maybe we can hide this functionality behind a flag such as --check-for-value-updates, so it doesn't affect regular usage.

@aryan9600
Copy link
Contributor Author

One more approach we can take is to combine the upgrade and bump process under one command and make it interactive. For example, after all the images are upgraded, we could prompt the user and ask whether they want to bump the chart as well. This way you can run the new command several times to try and upgrade images without bumping the version twice. The drawback here is that its not CI friendly and you need to know analyze which images got updated.

@alexellis
Copy link
Owner

alexellis commented Jan 23, 2024

Hi @aryan9600

I like your suggestion to use git.

Could we go go-execute to execute "git status" and then just scan if there's a values.yaml affected from the output?

Go bindings to git may require CGO, which I'd like to avoid.

Let me know if you think that's feasible?

For instance:

$ git status --short
 M chart/inlets-uplink/Chart.yaml
 M chart/inlets-uplink/values.yaml

Alex

@aryan9600
Copy link
Contributor Author

We could also use go-git if we wanted to do things in a more programatic manner. But then again, if you don't want to introduce several packages for one feature, we could go the go-execute route.

@alexellis
Copy link
Owner

Do you want to go ahead and try go-execute please?

@alexellis
Copy link
Owner

The functionality looks good now, I'd like the user experience to be consistent and to default to doing the obvious thing:

	arkade chart upgrade --verbose=$(VERBOSE) -w -f ./chart/openfaas/values.yaml && \

So, here's how the bump may work:

	arkade chart bump --verbose=$(VERBOSE) -w -f ./chart/openfaas/values.yaml

Please always bump the patch version by default, if maintainers want to bump major or release version, they can do that manually.

One other thought to bear in mind is that if any file in the folder of values.yaml has changed, then a bump is needed. I.e. you added an environment variable to a template YAML file.

@alexellis
Copy link
Owner

@aryan9600 hey are you still working on this?

Add a new command `arkade chart bump --dir ./chart` to bump the minor
of a Helm chart version. To bump multiple charts at once, specify the
parent directory with the `--recursive` flag. By default, the changes
are written to stdout. Specifying the `--write` flag writes the
changes to the respective file.

Signed-off-by: Sanskar Jaiswal <[email protected]>

njndjnd
Add flag `--check-for-value-updates` to `arkade chart bump` which skips
bumping the chart version if the values file does not have any changes
according to the Git.

Signed-off-by: Sanskar Jaiswal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflow improvement - increment Chart.yaml version when updating values.yaml
2 participants