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

Feature: add Helm chart install mode #98

Merged
merged 16 commits into from
Sep 13, 2023
Merged

Conversation

knmsk
Copy link
Contributor

@knmsk knmsk commented Feb 2, 2022

Hi everyone,
I moved most of things out of kustomize to helm chart. I had some problems trying to set-up the MutationWebhookConfiguration and ValidatingWebhookConfiguration, if anyone can help with this i will be glad.
Also, i added some liveness and readiness probe configuration on the controller-runtime in case someone will need it too due to requirements of the company cluster.

Closes #92

@yorugac yorugac self-requested a review February 3, 2022 11:56
@AbdelrhmanHamouda
Copy link

Hello @knmsk,
Any plans to have this as part of the 0.0.7 release?

@knmsk
Copy link
Contributor Author

knmsk commented Feb 21, 2022

probably after the discussion of issue #92

@CLAassistant
Copy link

CLAassistant commented Apr 4, 2022

CLA assistant check
All committers have signed the CLA.

@guillermotti
Copy link
Contributor

Hi @knmsk!!

Do you know when this PR will be merged? I created a custom Helm Chart meanwhile but would be great to use the official one.

Thanks for your work! Amazing ❤️

@knmsk
Copy link
Contributor Author

knmsk commented May 15, 2022

Hi @knmsk!!

Do you know when this PR will be merged? I created a custom Helm Chart meanwhile but would be great to use the official one.

Thanks for your work! Amazing ❤️

@guillermotti i thought about having a helm and a operator format to use, so probably i'll undo the operator removal and ask @yorugac to review it. But at my company we already use this PR to deploy our k6-operator

@yorugac
Copy link
Collaborator

yorugac commented May 23, 2022

Hi @knmsk! My apologies for such a terrible delay but I'm finally getting to your PR 😅

This is just a heads-up as I've only started looking at the PR and testing: I'll go through all details and then add any further comments. This is really neat, and I'm amazed it covers everything, including CI!

The main thing I wanted to mention for now is the UX one: I think we should avoid adding Helm as default build everywhere. I.e. it should be an option, not a requirement. Meaning, Makefile should support both kustomize and Helm, and CI tests running separately for both. WDYT on changing approach to having Helm as an option?

I was also thinking to update controller-gen separately as there seems to have been issues with installation. But here this update is included as part of PR. If it is updated separately, this PR might need a rebase.

@phlegx
Copy link

phlegx commented Jun 28, 2022

Hi there! What is the status of this Pull Request. We would need this Helm way as well!

@yorugac
Copy link
Collaborator

yorugac commented Jul 4, 2022

Hi @phlegx, this PR is planned to be merged for the next big release, v0.0.8. The release will not be earlier than August / September, but hopefully, Helm support itself will be merged before that.

@yulianovikova
Copy link

Hi!
Is this PR still planned for the v0.0.8 release? As far as I can see, 0.0.8rc1 does not include this feature yet :( Maybe you could also tell me when Helm support is planned to be released?
We are looking forward to this feature to be merged. Thank you!

@yorugac
Copy link
Collaborator

yorugac commented Sep 23, 2022

Hi @yulianovikova,

Unlike k6, k6-operator does not have any set schedule around releases. The reason is simple: the time resources allocated for it are limited and workload is impacted by external requests and now major issue #138. So previous estimation became invalid. I still would like to add Helm first but cannot say the dates at the moment. TBH, I'm not happy about this either. I'll try to see if anything can be improved and will update again if / when there are changes.

For now, I added next pre-release v0.0.8-rc3 (the rc2 has a CI issue), to have a new proper tagged image.

@StianOvrevage
Copy link

I also had a look at the PR. Looks very thorough and good.

Only thing I would like to mention is the lack of the standard/recommended K8s & Helm labels: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ & https://helm.sh/docs/chart_best_practices/labels/ .

If you create a helm chart with helm create test you'll get a _helpers.tpl file with some functions that are very widely used, such as:

{{/*
Common labels
*/}}
{{- define "test.labels" -}}
helm.sh/chart: {{ include "test.chart" . }}
{{ include "test.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

And it's used in deployment.yaml like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "test.fullname" . }}
  labels:
    {{- include "test.labels" . | nindent 4 }}

I don't include namespace in the templates since that's only redundant when passing --namespace to helm anyway, and would only cause problems and confusion if forgotten or misconfigured in the templates. But probably more of a personal opinion than pure fact.

The scaffold helm create charts also contain a few more configurable options on a Deployment that I think would be important for some:

  • affinity
  • nodeSelector
  • tolerations

@Dariusch
Copy link

Dariusch commented Dec 6, 2022

while we are at it:
Is the prometheus ServiceMontitor really necessary? Afaik prometheus metrics are pushed to the remote write gateway and not scraped (via a ServiceMonitor).

Copy link

@mclite mclite left a comment

Choose a reason for hiding this comment

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

Any updates on this? I'd like to start using it my company. Also can you make sure the Helm chart gets added to AWS EKS Blueprints

@knmsk knmsk requested review from mclite and Dariusch and removed request for yorugac and mclite March 11, 2023 15:39
@knmsk knmsk changed the title Feature moving to Helm from Kustomize Feature: add Helm chart install mode Mar 11, 2023
@knmsk
Copy link
Contributor Author

knmsk commented Mar 11, 2023

I've updated the code with the suggestions that @StianOvrevage and @Dariusch mentioned

while we are at it:
Is the prometheus ServiceMontitor really necessary? Afaik prometheus metrics are pushed to the remote write gateway and not scraped (via a ServiceMonitor).

@Dariusch I think it isn't necessary anymore, can @yorugac or someone confirm this?

@mclite
Copy link

mclite commented Mar 13, 2023

Ill test this in the next few days

@zalbiraw
Copy link

Any updates? :)

@chrisduong
Copy link

chrisduong commented Apr 11, 2023

I had used this chart, and haven't found any major issues. Please merge asap 🙂

@danielfigueiredo
Copy link
Contributor

danielfigueiredo commented Apr 13, 2023

I tried installing this branch by doing:

helm package /path/to/charts/folder
helm install k6-operator-0.0.1.tgz

But got a few errors because the template output (after processing) wasn't producing valid k8s resources. Nothing big, but I made a PR against @knmsk 's branch with minor fixes after I got a successful install, followed by successful test runs using the newly installed operator.

It would be fantastic if we could get this merged! It facilitates installs on private company repositories using the apps of apps pattern, and I believe it might significantly help with adoption 😄

@vazhnov
Copy link

vazhnov commented Apr 19, 2023

I've successfully installed the K6 operator from Helm chart with the freshest code changes.
I think it is good time to merge the changes. Any improvements can be done in new merge requests.

@knmsk
Copy link
Contributor Author

knmsk commented Apr 19, 2023

Hey @danielfigueiredo can you also sign the licence/cla?
I want to get this PR ready, so when a Maintain wants to merge it, it's ok

@danielfigueiredo
Copy link
Contributor

danielfigueiredo commented Apr 21, 2023

Hey @danielfigueiredo can you also sign the licence/cla? I want to get this PR ready, so when a Maintain wants to merge it, it's ok

Thanks for the prompt @knmsk , CLA signed!

Not sure why it hasn't updated yet, maybe there is a refresh cycle. The agreement is signed and my email used is my primary email for this github account so should all be good. I'll keep an eye but please let me know if there is anything else missing here

@JeffCT0216
Copy link

JeffCT0216 commented May 4, 2023

Thanks @knmsk for working on this!
I'm currently waiting for this to be merge to deploy using helm, is there an estimate on when this will be merged?

@Dariusch

@yorugac
Copy link
Collaborator

yorugac commented Aug 18, 2023

It seems there was a somewhat similar case of CLA confusion over here:
grafana/mimir-prometheus#269 (comment)

Apparently, making a "Co-authored-by" commit allowed to bypass the problem. Github docs on such commits. It's still strange but perhaps that could work here as well.
cc @danielfigueiredo @knmsk

@knmsk
Copy link
Contributor Author

knmsk commented Aug 18, 2023

Just to make sure that I got it, I need to make a commit with a manual co-authored-by @danielfigueiredo to bypass this problem, right?

@danielfigueiredo
Copy link
Contributor

Okay, @knmsk I just managed to fix it!
Ended up adding the other email to my github account temporarily so that w can bypass this issue
should be unblocked now
thanks @yorugac for all the help too

@knmsk
Copy link
Contributor Author

knmsk commented Aug 18, 2023

Sorry, had to do a rebase since I've got some merge problems that I usually not run into 😢

EDIT: Got it!

knmsk and others added 11 commits August 18, 2023 13:36
Added missed PodSecurityContext in K6 CRD.
Tested in minikube with default e2e/test.js
author knmsk <[email protected]> 1643746211 -0300
committer knmsk <[email protected]> 1692377913 -0300

changed the build to helm instead of kustomize

changed the build to helm instead of kustomize

changed to helmlint

moved the charts folder

fix: helpers rendering namespace incorrectly

Added chart-testing workflow

fix: ct list-changed

fix: chart-testing only when has differences

fixed the image from the samples

revert: remove the kustomize, now supports both

revert: changes on go.mod

fix the image build

fix: makefile identation

revert: controller-gen version 0.4.0 to 0.3.0

fix: makefile bundle error

fix: yamllint file on github actions
Added missed PodSecurityContext in K6 CRD.
Tested in minikube with default e2e/test.js
apply suggestions

fix: e2e-test for kustomize

fix: makefile tab
Copy link
Collaborator

@yorugac yorugac left a comment

Choose a reason for hiding this comment

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

@knmsk, this is an amazingly large work, thanks! 😄

I've gone through the main points: most of the change requests are small and should be relatively quick to fix. Quite a few of them seem to be just leftovers because of rebasing lots of commits at once.

Other than those leftovers, most noticeable change request is around names: see the comment in _helpers.tpl. As it is, the installation doesn't work for me ATM.

There are also a couple of questions I'd like to clarify with you, e.g. in values.yaml and Makefile.

Btw, thank you for including CI workflows! One of the main blockers for merging this was the additional effort required to maintain the chart: working CI would help with that 👍 I hope they'll work out-of-the-box.

.github/workflows/chart-test.yaml Outdated Show resolved Hide resolved
.github/workflows/e2e-test-helm.yaml Outdated Show resolved Hide resolved
.github/workflows/helmlint.yaml Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
charts/values.yaml Outdated Show resolved Hide resolved
charts/samples/customAnnotationsAndLabels.yaml Outdated Show resolved Hide resolved
charts/templates/crds/k6.yaml Show resolved Hide resolved
charts/values.yaml Outdated Show resolved Hide resolved
charts/templates/_helpers.tpl Show resolved Hide resolved
Copy link
Collaborator

@yorugac yorugac left a comment

Choose a reason for hiding this comment

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

The changes are working as far as I checked 🙌 There will probably be small adjustments we'll have to do in the future but otherwise, it looks pretty neat!

@knmsk, I'm marking this as a change request because of bundle/: I'm not clear why it was added. We might return to it if we ever get to #3 but it shouldn't be required for Helm support, AFAIS. Could you please remove it?

A note for the future: each update of CRD(s) will need to be copy-pasted to the charts/templates/crds in order to be picked up by the next chart release.

charts/values.yaml Outdated Show resolved Hide resolved
@knmsk knmsk requested a review from yorugac September 6, 2023 21:06
@knmsk
Copy link
Contributor Author

knmsk commented Sep 6, 2023

@yorugac yeah, its not supposed to have a bundle folder committed at least.
done making the changes! Can you take a look again please?

Copy link
Collaborator

@yorugac yorugac left a comment

Choose a reason for hiding this comment

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

LGTM! The scenarios I've tested work and the structure is straight-forward 👍

Thank you again for the work and updates and esp. patience, @knmsk and everyone who helped 😄

Comment on lines +164 to +208
# permissions for end users to edit privateloadzones.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: privateloadzone-editor-role
rules:
- apiGroups:
- k6.io
resources:
- privateloadzones
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- k6.io
resources:
- privateloadzones/status
verbs:
- get
---
# permissions for end users to view privateloadzones.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: privateloadzone-viewer-role
rules:
- apiGroups:
- k6.io
resources:
- privateloadzones
verbs:
- get
- list
- watch
- apiGroups:
- k6.io
resources:
- privateloadzones/status
verbs:
- get
Copy link
Collaborator

Choose a reason for hiding this comment

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

These roles are not actually included by default:
https://github.com/grafana/k6-operator/blob/main/config/rbac/kustomization.yaml
The same as with k6-editor-role and k6-viewer-role.
At first glance, these don't seem to make an impact one way or another so ~ future candidates for removal.

@yorugac yorugac merged commit 2967283 into grafana:main Sep 13, 2023
2 checks passed
@yorugac yorugac added this to the 0.11 milestone Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement Request] Refactor kustomize to a helm chart template