Skip to content

Templatize helm template image references #20066

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

Merged
merged 11 commits into from
Jun 13, 2022

Conversation

joestringer
Copy link
Member

@joestringer joestringer commented Jun 2, 2022

From the main commit:

Move all of the declarations of the image repositories and tags into
install/kubernetes/Makefile.values, then templatize the values file so
that we can pick up these env variables using envsubst. Then we can get
rid of the big ugly 'sed' hack in the Makefile which is hard to maintain.

Broadly this PR moves the install/kubernetes/cilium/values.yaml to install/kubernetes/cilium/values.yaml.tmpl as the source of truth. This new values file template has variables wherever the docker repositories and tags are.

Inside the Makefiles, we declare the repos/tags as variables, then when we run envsubst against the install/kubernetes/cilium/values.yaml.tmpl, it substitutes the variables into the template and generates the final output install/kubernetes/cilium/values.yaml file.

This looks like a big change (~2KLoC), but most of it is just making a copy of install/kubernetes/values.yaml in order to templatize it. Review commit-by-commit to see incremental changes.

This PR also fixes the default helm in the master branch to point towards quay.io/cilium/cilium-ci:latest so that you can install directly from the repo. When we branch for the next release, we will update the repo and tag to point to the branch instead and then the helm charts should work for that target development branch.

You can also override these default settings by making your own copy of install/kubernetes/Makefile.values and then running this with MAKEFILE_VALUES=/path/to/my/values.mk make -C install/kubernetes.

@joestringer joestringer requested a review from a team June 2, 2022 21:34
@joestringer joestringer requested review from a team as code owners June 2, 2022 21:34
@joestringer joestringer added the release-note/misc This PR makes changes that have no direct user impact. label Jun 2, 2022
@joestringer joestringer requested review from sayboras and aditighag June 2, 2022 21:34
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 2, 2022
@joestringer joestringer requested a review from pchaigno June 2, 2022 21:34
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 2, 2022
@joestringer joestringer force-pushed the submit/improve-version-tracking branch 2 times, most recently from 90ce1c7 to ba5a725 Compare June 2, 2022 21:56
OPERATOR_ALIBABACLOUD_DIGEST := ""
OPERATOR_GENERIC_DIGEST := ""
OPERATOR_DIGEST := ""
export CILIUM_DIGEST := ""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative to all this exporting is to just blanket export all variables to subshells via .EXPORT_ALL_VARIABLES as a Special Target, but I wasn't sure if that might cause other issues since I don't know if that's scoped only to this Makefile or whether it could end up exporting other vars.

Copy link
Contributor

@michi-covalent michi-covalent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm just one question about phony target. this is much cleaner 🚢

@joestringer joestringer force-pushed the submit/improve-version-tracking branch from ba5a725 to 8976587 Compare June 2, 2022 22:55
Copy link
Member

@aditighag aditighag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tidying up the Makefiles, and fixing the defaults with "-ci" image tags.

Comment on lines +1 to +2
# File generated by install/kubernetes/Makefile; DO NOT EDIT.
# This file is based on install/kubernetes/cilium/values.yaml.tmpl.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was this file generated? Helm?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's generated using envsubst. Maybe I could have described this better in the PR description. Broadly what this PR does is it adds a bunch of exported variables in install/kubernetes/Makefile.values, then runs envsubst which takes in the values.yaml.tmpl on stdin plus the environment variables, then substitutes all of the variables in the template and writes out to this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ I expanded the PR description to help explain this, hopefully that makes sense now.

$(ECHO_GEN)$@
echo -e "# File generated by $(RELATIVE_DIR)/Makefile; DO NOT EDIT." > $@
echo -e "# This file is based on $(RELATIVE_DIR)/cilium/values.yaml.tmpl.\n" >> $@
envsubst < $< >> $@
Copy link
Member Author

@joestringer joestringer Jun 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the magic line, basically take $< (the template file, first dependency in the list) as stdin to envsubst, which also takes the exported environment variables as inputs, then redirect the output to $@ (the target values.yaml file).

@joestringer joestringer requested a review from a team as a code owner June 2, 2022 23:23
@joestringer joestringer requested a review from qmonnet June 2, 2022 23:23
@joestringer joestringer force-pushed the submit/improve-version-tracking branch from 0c0bba3 to bed5b6b Compare June 2, 2022 23:27
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joestringer! Couple of comments but overall LGTM.

On the CI side, test-smoke.yaml should detect changes to values.yaml.tmpl without a corresponding values.yaml update:

- name: Run helm-charts
run: |
make -C install/kubernetes
test -z "$(git status --porcelain)" || (echo "please run 'make -C install/kubernetes' and submit your changes"; exit 1)

Looking at this workflow, "Run helm-docs" seems extraneous because "Run helm-charts" execute make -C install/kubernetes and the default all target has the docs target as dependency. As this is kind of related to this PR, would you mind adding a commit to fix this (either remove "Run helm-docs" or make "Run helm-charts" execute the update-versions target)? Happy to open another PR if you prefer.

@joestringer joestringer force-pushed the submit/improve-version-tracking branch from bed5b6b to d6203ec Compare June 3, 2022 18:09
@joestringer joestringer requested a review from kaworu June 3, 2022 18:09
@joestringer
Copy link
Member Author

Addressed @kaworu's feedback, mainly with two new commits on top. Should reduce the amount of duplicate work on the tests-smoke.yaml GHA linting side, and properly track dependencies as well.

Copy link
Member

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only reviewed the changes falling under my codeowners, but LGTM.

@joestringer joestringer force-pushed the submit/improve-version-tracking branch from d6203ec to 7fc4299 Compare June 6, 2022 16:57
Default these helm templates to install the latest version from the tip
of master, for easy development.

Signed-off-by: Joe Stringer <joe@cilium.io>
Signed-off-by: Joe Stringer <joe@cilium.io>
Split up the variables used here for better readability, and add the V=0
quiet line to indicate progress in the way the other targets do.

Signed-off-by: Joe Stringer <joe@cilium.io>
The 'docs' target under install/kubernetes is already run by the
'helm-charts' step via the 'all' make target. Given some of the recent
re-organizing, we should probably just add linting to the overall steps
in the makefile and run all of the targets.

This should avoid running these targets twice:
* 2x Run cilium/values.yaml generation (via lint, all targets)
* 2x Run docs (via docs, all targets)

Suggested-by: Alexandre Perrin <alex@isovalent.com>
Signed-off-by: Joe Stringer <joe@cilium.io>
Previously this script wouldn't work when invoked on the master branch
via `make -C install/kubernetes check-docker-images`, because the script
expected some images to be present on dockerhub when we don't keep them
up to date there (startup-script, cilium-etcd-operator), and also
because the tree specifies the image tag as "latest" which are only
published on the quay.io/cilium/*-ci repositories. Teach the script to
pick up the correct set of image dependencies to handle these cases.

Signed-off-by: Joe Stringer <joe@cilium.io>
@joestringer joestringer force-pushed the submit/improve-version-tracking branch from 3bd8dc9 to bab8e48 Compare June 13, 2022 17:09
@joestringer joestringer merged commit 3ec10e7 into cilium:master Jun 13, 2022
@joestringer joestringer deleted the submit/improve-version-tracking branch June 13, 2022 20:27
@joestringer joestringer added backport-pending/1.11 backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. and removed needs-backport/1.11 labels Jun 13, 2022
michi-covalent added a commit that referenced this pull request Jun 14, 2022
Following up on #20066, templatize preflight and clustermesh-apiserver
repos.

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
joestringer pushed a commit that referenced this pull request Jun 15, 2022
Following up on #20066, templatize preflight and clustermesh-apiserver
repos.

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-done/1.11 The backport for Cilium 1.11.x for this PR is done. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants