-
Notifications
You must be signed in to change notification settings - Fork 190
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
charts: Add helm charts for Inspektor Gadget #1707
Conversation
4541472
to
c4a252a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with charts publishing process, so I did not review this part of the PR, but manifests etc looks good. Left some questions/suggestions.
charts/Makefile
Outdated
sed -i "s/%VERSION%/$(CHART_VERSION)/g" $(CHART_DIR)/Chart.yaml | ||
sed -i "s/%APP_VERSION%/$(IMAGE_TAG)/g" $(CHART_DIR)/Chart.yaml | ||
@echo "Preparing docs" | ||
docker run --user $(shell id -u):$(shell id -g) -v $(shell pwd)/$(CHART_DIR):/helm-docs jnorwood/helm-docs:v1.11.0 -s file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jnorwood/helm-docs:v1.11.0
could also be in a variable in case an override is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
charts/Makefile
Outdated
@echo "Charts available at: $(CHART_DIR)" | ||
|
||
install: build | ||
$(HELM) install gadget $(CHART_DIR) --namespace gadget --create-namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe namespace could be a variable as well? Is it supported to deploy IG in other namespaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IG daemonset itself might be fine in different namespace but the client kubectl-gadget
expects the pod to be in gadget namespace so perhaps we keep this way. @mauriciovasquezbernal do you have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case, perhaps all resources should have this namespace hardcoded then? As installing in other namespace will result in broken scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all resources should have this namespace hardcoded then?
Good Point, I refactored the templates to use hardcored "gadget" namespace.
@@ -0,0 +1,6 @@ | |||
{{ if .Values.createNamespace }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this manifest is not necessary. IIRC Helm will complain if target namespace does not exist and --create-namespace
flag is not specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it. This was a workaround for helm template not adding namespace in the generated manifest :( but makes sense to move this out of charts.
charts/Makefile
Outdated
@echo "Charts available at: $(CHART_DIR)" | ||
|
||
install: build | ||
$(HELM) install gadget $(CHART_DIR) --namespace gadget --create-namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would make sense to use helm upgrade --install
+ kubectl apply
for CRDs (as helm upgrade
does not update CRDs) to be able to iterate on chart when developing it? install
is not idempotent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks for a suggestion. The flow is much better now!
c4a252a
to
5107b97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@invidian Thank you so much for the review!
charts/Makefile
Outdated
sed -i "s/%VERSION%/$(CHART_VERSION)/g" $(CHART_DIR)/Chart.yaml | ||
sed -i "s/%APP_VERSION%/$(IMAGE_TAG)/g" $(CHART_DIR)/Chart.yaml | ||
@echo "Preparing docs" | ||
docker run --user $(shell id -u):$(shell id -g) -v $(shell pwd)/$(CHART_DIR):/helm-docs jnorwood/helm-docs:v1.11.0 -s file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
charts/Makefile
Outdated
@echo "Charts available at: $(CHART_DIR)" | ||
|
||
install: build | ||
$(HELM) install gadget $(CHART_DIR) --namespace gadget --create-namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks for a suggestion. The flow is much better now!
charts/Makefile
Outdated
@echo "Charts available at: $(CHART_DIR)" | ||
|
||
install: build | ||
$(HELM) install gadget $(CHART_DIR) --namespace gadget --create-namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IG daemonset itself might be fine in different namespace but the client kubectl-gadget
expects the pod to be in gadget namespace so perhaps we keep this way. @mauriciovasquezbernal do you have any thoughts on this?
@@ -0,0 +1,6 @@ | |||
{{ if .Values.createNamespace }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it. This was a workaround for helm template not adding namespace in the generated manifest :( but makes sense to move this out of charts.
4dfc944
to
423bd4c
Compare
{{/* | ||
Namespace used by all resources. | ||
*/}} | ||
{{- define "gadget.namespace" -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea for still using a template for the namespace in case this changes in the future!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I watched your presentation about it and it seems cool.
I nonetheless need to gain more knowledge about helm
to test it and then give an approval.
charts/Makefile
Outdated
# also helm upgrade does not update CRDs so we need to apply them separately | ||
install: build | ||
$(HELM) upgrade --install gadget $(CHART_DIR) --namespace gadget --create-namespace | ||
kubectl apply -f $(CHART_DIR)/crds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kubectl apply -f $(CHART_DIR)/crds | |
kubectl apply -f $(CHART_DIR)/crds/* |
?
Same for below.
kind: Role | ||
kind: ClusterRole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it OK to change the order of the stuff there?
Wouldn't it be possible for the deploy to fail if B is defined before A while needing A?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, It might be problem like if namespace
is moved in the end we will run into errors. But here we only swap ClusterRole
and Role
which aren't related so should be fine. Helm decide to order them like that as mentioned in this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments. I'm a bit worried about the handling of the latest
version.
I was on this branch, I did:
$ make -C charts/ install
...
Inspektor Gadget 0.17.0 installed successfully
That was surprising as I was expecting the current version to be installed. Is that the expected version to install the last release?
charts/Makefile
Outdated
OUTPUT_DIR ?= $(BUILD_DIR) | ||
CHART_DIR := $(BUILD_DIR)/gadget | ||
|
||
IMAGE_TAG := $(shell git describe --tags --abbrev=0 --match "v*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a script to get the tag: tools/image-tag. It has some additional logic to take the name of the branch into consideration. Should we use it here too?
Btw, if I'm on main and I run make template
it'll use the latest version instead of latest
as tag. Is that the desired behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I wasn't too sure about it. I was trying to have 1:1 versioning between chart version
and appVersion
and that is making it confusing. Chart Version is suppose to be semver and hence tools/image-tag
won't work for it so I used on my own way of handling it. But I agree we should use tools/image-tag
for appVersion
this should make the behavior exactly like deploy
command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do other folks handle the chart version of the "latest" app? Or they aren't charts available for "latest" apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the charts are living outside so they perhaps don't care about latest
. Having said that, one can have dev versions (1.0.0-dev
) for both chart/app and use --set image.tag=$IMAGE_TAG
(e.g cilium) installation and worry about versioning only for releases. What we did now should work fine but in case it gets confusing we can rework it in future?
charts/Makefile
Outdated
$(HELM) uninstall gadget --namespace gadget | ||
kubectl delete -f $(CHART_DIR)/crds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be done the other way around? This is how we do this in the deploy command
// 2. remove crd |
Also, what happens to the traces CR?: they need the operator to be running to be able to remove it, otherwise the finalizer will never let them be removed. In the undeploy command we have some logic to handle this
// 1. remove traces |
I agree we can just simply say it's the user's responsibility to delete them before if this is difficult to handle.
@echo "Charts available at: $(CHART_DIR)" | ||
|
||
# install uses 'helm upgrade --install' to make chart installation idempotent, | ||
# also helm upgrade does not update CRDs so we need to apply them separately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:( this is too bad as users will have to handle additional commands manually.
According to helm/helm#8668 (comment):
If you're chart doesn't install custom resources just the CRDs... you can put the CRDs right into the templates directory.
That seems to be our case. Perhaps we can investigate more to see if we can improve this. Anyway, I'll agree this an improvement and not a blocker for this PR.
56e3999
to
e690d5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ready to go! Thanks for handling this!
charts/Makefile
Outdated
CHART_DIR := $(BUILD_DIR)/gadget | ||
|
||
# CHART_VERSION must be a valid SemVer string so strip the leading 'v' | ||
CHART_VERSION ?= $(shell git describe --tags --always | sed 's/^v//') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use something like 0.9999.0
to avoid any kind of confusion between app and chart version? (Don't hesitate to say not if it doesn't make sense at all)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
e690d5c
to
5f62055
Compare
Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
5f62055
to
e341492
Compare
Thanks for all the reviews! :) |
This PR introduces helm charts for Inspektor Gadget. The idea is to have a single source of truth for
deploy
command as helm charts to avoid running into issues in future. The current approach will reuse the CRDs in both installation workflows. In case of manifest, helm will be source of truth and helm generated manifest is used as base (deploy.yaml
) fordeploy
command. In terms of versioning, I want to start with 1:1 versioning between chart version and app version since it is simple and recommend in the start and app version will used for container image tag unless specified.For publishing we will setup a index like here using
helm repo index ...
but pointing to charts in our release assets. I want this change to go in and then automate that step.Related: #414
Testing done
$ make minikube-start $ make -C charts APP_VERSION=latest install NAME: gadget LAST DEPLOYED: Fri Jun 2 17:31:35 2023 NAMESPACE: gadget STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: Inspektor Gadget latest installed successfully! For usage details, visit https://www.inspektor-gadget.io $ kubectl get pods -n gadget NAME READY STATUS RESTARTS AGE gadget-nsrx2 1/1 Running 0 2m30s
You can verify the charts using:
Ensuring no regression in deploy.yaml
Todo