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

Adding k3s support in helm chart #22

Closed
wants to merge 4 commits into from
Closed

Conversation

unixbird
Copy link
Contributor

Normally you would have to edit the DaemonSet to add the k3s containerd path so that the cluster collector would get metrics properly but with this you can enable k3s in the values.yml to do it for you.

I tested this on a brand new k3s instance and it works for me with data in the checkmk dashboard.

added k3s as a flag for k3s clusters.
added the k3s containerd path if k3s is enabled in the values.yml
@github-actions
Copy link

github-actions bot commented Aug 18, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@unixbird
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.

@@ -6,6 +6,9 @@ nameOverride: ""
fullnameOverride: ""
kubeVersionOverride: ""

k3s:
Copy link
Member

Choose a reason for hiding this comment

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

As this change also adds support for RKE2, please also add it and let's rename it for more clarity to:
k3s/rke2-compatibilityMode

Copy link
Contributor

Choose a reason for hiding this comment

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

I would advise against using special characters like - or / in the variable names in Helm ... plain camelCase would be best!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with this as the user would most likely have to escape it to use it (I'm guessing). Should I rename it to k3sbackend or rancherbackend? Not sure what to rename it to

@martinhv
Copy link
Member

Hey Zach!
Thanks for your first contribution.
Please check the comments I added.

@martinhv
Copy link
Member

For the future: ideally the commits individually should speak for themselves. E.g. updating a filename becomes very obvious when you see that the commit only touched the one filename. In this case, I would have recommended one commit which includes both changes and use the title of this PR for the commit :-)

@@ -62,6 +62,9 @@ spec:
args:
{{- with .Values.nodeCollector.cadvisor.additionalArgs }}
{{ toYaml . | nindent 12 }}
{{- if $.Values.k3s.enabled }}
Copy link
Member

Choose a reason for hiding this comment

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

Why do you use {{- if $.Values.k3s.enabled }} instead of {{- if .Values.k3s.enabled }} ?
I am no Helm template expert, but it loosk rather unusual.

Copy link
Contributor

Choose a reason for hiding this comment

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

You have to use $ if you are inside a loop or iteration (as here introduced with with statement), in order to access variables on global level; because inside a loop using . you would access variables inside the local context.

But nonetheless, why are we adding it inside the context in the first place? For me this reads like, for each additionalArg we add, if k3s is enabled, also add --containerd ... but we would like to only add it once, no?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it would be better to do this outside the context.
We only need to add --containerd once, if the user is using k3s or rke2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it does just add it once and there was a weird thing I had happen to me where it actually added the other additionalArgs 2 times instead of once. The version you see here doesn't do that (at least for me). It just adds 1 containerd arg line after the original additionalArgs.

@sjentzsch
Copy link
Contributor

Two general questions on this:

  1. Do we even want to add another flag? Users can already add the arg by adding - "--containerd=/run/k3s/containerd/containerd.sock" to the Helm value nodeCollector.cadvisor.additionalArgs. It's already a list of additional args that can be added. We could add
      # uncomment to add support for k3s/RKE2, see https://github.com/k3s-io/k3s/issues/2831
      #- "--containerd=/run/k3s/containerd/containerd.sock"

though to the default samples, so it's ready to be uncommented. @unixbird you were mentioning "you would have to edit the DaemonSet to add the k3s containerd path" - were you aware of nodeCollector.cadvisor.additionalArgs?

  1. According to cAdvisor metrics stopped working correctly in K3s 1.20 k3s-io/k3s#2831 (comment) with latest 1.24 patch release onwards this should not be required anymore for k3s newer versions. Did not test myself; which version were you using @unixbird when testing?

@unixbird
Copy link
Contributor Author

@sjentzsch I just tested this with 1.27.5 and the cluster collector fails without using those additional args.

I was thinking of the same thing but Martin thought of something else to try out and I like it a little better than what I originally had. Going to edit it into this PR for review.

Added suggested changes to instead include a way to customize the containerd runtime path.
Adjusted to match the values.yml to allow customization of where the containerd runtime path is.
@unixbird
Copy link
Contributor Author

Added the changes that @martinhv suggested to my main branch. This allows you to customize the location of the containerd runtime if needed.

Copy link
Member

@martinhv martinhv left a comment

Choose a reason for hiding this comment

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

Works for me. Will forward to a dev.

@CheckmkCI CheckmkCI closed this in 2bfcf8f Sep 18, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants