k8s-sentry icon indicating copy to clipboard operation
k8s-sentry copied to clipboard

✨ Implement Helm chart + add Makefile for command shortcuts + update README

Open daaain opened this issue 3 years ago • 11 comments

Fixes #11

NOTE: will need Github Pages enabled on /docs in master!

I'm ready with the first draft, I just deployed it in our test cluster for all namespaces and seems to be working nicely.

I've temporarily changed the URL to point to my fork to make it possible for Helm to download, but will change this once we're ready to merge.

So to try it right now, you can use these commands:

helm repo add k8s-sentry https://daaain.github.io/k8s-sentry
helm repo update
helm install k8s-sentry/helm-k8s-sentry --set sentry.dsn=<your Sentry DSN value>

The default is all namespaces and no environment so it will do that if you only pass the DSN, otherwise can customise by changing values with --set. I haven't tried all combinations of options yet.

As for the Helm repo hosting, I went with the absolute simplest solution which is to package the chart locally and commit the repo index YAML and chart archives in git. The chart archive is currently ~1KB so even though it's binary, the size is tiny so I don't see any issue storing it in git. So this is the most transparent and least setup way to do it, but the trade-off is having to remember to package the chart with make helm_package whenever it's updated. This could also be done in a Github Action, but that would need to commit on a gh-pages branch which needs a bit more setup.

Also, I've duplicated the templates from the deploy directory, but it would be nicer to somehow reuse them. There is already a make helm_template command which renders the templates to stdout, so that could easily be developed into a way to programmatically write all different versions of the k8s templates in deploy by changing the options passed and the output directories.

Let me know what you think!

daaain avatar Oct 09 '20 11:10 daaain

Oh, one thing which I just realised is that it would probably be useful to link the versions of the Helm chart to the versions of the binary so that people can easily understand and manage the upgrade process.

In that case, the Helm chart archives could also be stored on Github Releases and linked from there, though I haven't quite figured out where to store and update the repo index YAML in that case.

daaain avatar Oct 09 '20 13:10 daaain

Hey @wichert, do you think you'll have time to review and comment on this?

It's fine if you don't, I can also spin this out into a separate repo, just let me know.

daaain avatar Nov 26 '20 10:11 daaain

You will need a name for the helm install command, like: helm install sentry k8s-sentry/helm-k8s-sentry --set sentry.dsn=<your Sentry DSN value>

frankyhun avatar Dec 09 '20 15:12 frankyhun

Btw. if you want to try the helm chart right now, you have to add the replo like this: helm repo add k8s-sentry https://raw.githubusercontent.com/daaain/k8s-sentry/master/docs/

frankyhun avatar Dec 09 '20 15:12 frankyhun

Ah, thanks @frankyhun, I'm using the chart via Helmfile so was just typing the Helm commands into the readme directly 😳 Will update in a minute.

daaain avatar Dec 11 '20 11:12 daaain

I'm not sure, but looks a bit ambiguous, that somewhere SENTRY_DSN environment value is written, in somewhere sentry.dsn, in the yaml it is in sentry: dsn: format. Which one is the used one?

I tried it with aws cdk, set the SENTRY_DSN variable, but then it failed to start up.

frankyhun avatar Dec 11 '20 11:12 frankyhun

That is because while internally the Kubernetes template and application code is using SENTRY_DSN as environment variable, for Helm to be able to template it you need to set the Helm variable.

You can see in the source code how it's used: https://github.com/wichert/k8s-sentry/pull/12/files#diff-783271f5d9de279f32ef356eb2db9be73fc29e7ba25d6137c62a6185508b4b34R20

This is an unfortunate limitation of Helm, it doesn't play well with environment variables, this is one of the reasons why we use Helmfile.

You can take the value from an env var though, so you can:

helm install sentry k8s-sentry/helm-k8s-sentry --set sentry.dsn=$SENTRY_DSN

This is still nicer than having to manually edit the Kubernetes templates though!

daaain avatar Dec 11 '20 12:12 daaain

Maybe we can use github page as chartmuseum?

https://github.com/marketplace/actions/helm-chart-releaser

Example use: https://github.com/grafana/helm-charts/blob/main/.github/workflows/release.yaml

soloradish avatar Dec 23 '20 05:12 soloradish

just chiming in to say I'm looking forward to this, thanks for the work everyone :+1:

caleb15 avatar Dec 29 '20 23:12 caleb15

Any plan to push this further?

evolvedlight avatar Sep 27 '21 13:09 evolvedlight

I'm really sorry, but I don't think I'll have time in the near future so if anyone has some time to take over, please do!

daaain avatar Nov 01 '21 10:11 daaain