Skip to content

Add nameOverride and fullnameOverride support to Tetragon Helm chart #3604

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cy83rc0llect0r
Copy link
Contributor

Enhancement #2951

Description

This pull request adds support for nameOverride and fullnameOverride in the Tetragon Helm chart, addressing the enhancement request in issue #2951. This feature allows users to customize the names of Kubernetes resources deployed via Helm, improving flexibility and compatibility in diverse environments (e.g., when deploying multiple instances or following naming conventions).

The changes include:

  • Addition of nameOverride and fullnameOverride fields to values.yaml.
  • Introduction of a new tetragon.fullname helper in _helpers.tpl to unify naming logic across templates.
  • Updates to all affected templates (DaemonSet, Deployment, ServiceAccount, etc.) to use the new helper instead of .Release.Name.
  • Tested the changes using helm template to validate correct name rendering.

These changes are fully backward compatible: if nameOverride and fullnameOverride are not set, the chart behaves as before.

Use Case Example

A user deploying multiple instances of Tetragon (e.g., in different namespaces or clusters) can now avoid resource name collisions by customizing the full names of the Kubernetes objects. This is especially useful in CI/CD pipelines or large multi-tenant setups where naming conventions must be enforced.

Changelog

Added nameOverride and fullnameOverride support to the Tetragon Helm chart. Use these fields in values.yaml to customize resource names.

@cy83rc0llect0r cy83rc0llect0r requested a review from a team as a code owner April 7, 2025 21:57
@cy83rc0llect0r cy83rc0llect0r requested a review from tpapagian April 7, 2025 21:57
Copy link

netlify bot commented Apr 7, 2025

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 95a7785
🔍 Latest deploy log https://app.netlify.com/projects/tetragon/deploys/682ef78b216b9000083204f0
😎 Deploy Preview https://deploy-preview-3604--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mtardy mtardy added the release-note/minor This PR introduces a minor user-visible change label Apr 15, 2025
@cy83rc0llect0r cy83rc0llect0r force-pushed the pr/cy83rc0llect0r/add-nameOverride-to-helm-chart branch from fcd9f30 to 85476ec Compare April 15, 2025 09:10
@cy83rc0llect0r
Copy link
Contributor Author

@tpapagian Could you please find some time to review my PR? It's been pending for a while, and your feedback would be greatly appreciated to move it forward.
Thank you for your time and support!

@tpapagian
Copy link
Member

@tpapagian Could you please find some time to review my PR? It's been pending for a while, and your feedback would be greatly appreciated to move it forward. Thank you for your time and support!

Hey, sorry missed that review. This PR looks good to me. Thanks!

name: {{ include "tetragon-operator.serviceAccount" . }}
name: {{ include "tetragon.fullname" . }}-operator-service-account
Copy link
Member

Choose a reason for hiding this comment

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

here you don't use the tetragon-operator.serviceAccount name anymore, it seems it was missing the .name but maybe we still want that to work?

Copy link
Contributor Author

@cy83rc0llect0r cy83rc0llect0r Apr 23, 2025

Choose a reason for hiding this comment

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

@mtardy Thanks for the review! I understand you're concerned about switching from tetragon-operator.serviceAccount to tetragon.fullname for the serviceAccount name in operator_deployment.yaml and operator_serviceaccount.yaml. With the current setup, the serviceAccount name is tetragon-operator-service-account by default, and it changes to custom-operator-service-account when nameOverride=custom is set, which works correctly with RBAC (e.g., custom-operator-rolebinding).
To clarify, do you want the serviceAccount name to always remain tetragon-operator-service-account (regardless of nameOverride or fullnameOverride) to ensure compatibility with existing configurations? Or is the current behavior, where the name can change with nameOverride, acceptable? I can revert to tetragon-operator.serviceAccount and lock the name if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any comments? @mtardy

Copy link
Member

Choose a reason for hiding this comment

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

So as I understand this value is defined as such, if you have .Values.tetragonOperator.serviceAccount.name we use it otherwise it default to what you said.

{{- define "tetragon-operator.serviceAccount" -}}
{{- if .Values.tetragonOperator.serviceAccount.name -}}
{{- printf  "%s" .Values.tetragonOperator.serviceAccount.name -}}
{{- else -}}
{{- printf  "%s-operator-service-account" .Release.Name -}}
{{- end -}}
{{- end }}

So perhaps what you want to do in this PR is to change

- {{- printf  "%s-operator-service-account" .Release.Name -}}
+ {{ include "tetragon.fullname" . }}-operator-service-account

In this template no? Otherwise the value will be ignored

Copy link
Member

Choose a reason for hiding this comment

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

you might want to change tetragon's serviceaccount as well, it seems you skipped that:

{{/*
ServiceAccounts
*/}}
{{- define "tetragon.serviceAccount" -}}
{{- if .Values.serviceAccount.name -}}
{{- printf "%s" .Values.serviceAccount.name -}}
{{- else -}}
{{- printf "%s" .Release.Name -}}
{{- end -}}
{{- end }}

In the _helpers.tpl

Maybe grep for .Release.Name for the remaining stuff.

@@ -98,12 +98,12 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "tetragon-operator.serviceAccount" . }}
Copy link
Member

Choose a reason for hiding this comment

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

same here

@@ -2,7 +2,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "tetragon-operator.serviceAccount" . }}
Copy link
Member

Choose a reason for hiding this comment

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

same here

@mtardy
Copy link
Member

mtardy commented Apr 30, 2025

Aside I'll be off for the next two weeks, so feel free to ping someone else if you want to merge this earlier

@cy83rc0llect0r cy83rc0llect0r force-pushed the pr/cy83rc0llect0r/add-nameOverride-to-helm-chart branch from 85476ec to e786762 Compare May 21, 2025 20:26
@cy83rc0llect0r
Copy link
Contributor Author

My bad!
I accidentally created a wrong push and closed my PR!
Can you remove this and I will create new PR?
@mtardy

@mtardy
Copy link
Member

mtardy commented May 22, 2025

Can you remove this and I will create new PR?
@mtardy

Hey, what would you like to remove? This PR seems to be closed already.

@cy83rc0llect0r
Copy link
Contributor Author

Can you remove this and I will create new PR?
@mtardy

Hey, what would you like to remove? This PR seems to be closed already.

Yes it closed by my mistake :(

@mtardy
Copy link
Member

mtardy commented May 22, 2025

Can you remove this and I will create new PR?
@mtardy

Hey, what would you like to remove? This PR seems to be closed already.

Yes it closed by my mistake :(

I think you might be able to reopen it if you push commit to the branch again

- Added nameOverride and fullnameOverride fields to values.yaml at root level for customizable resource names.
- Introduced tetragon.fullname helper in _helpers.tpl to standardize naming across the chart.
- Updated all templates to use tetragon.fullname instead of .Release.Name for consistency in resources (DaemonSet, Deployment, ServiceAccount, etc.).
- Tested with helm template to ensure correct name rendering."

Enhancement cilium#2951

Signed-off-by: Amir Reza Nazarizadeh <[email protected]>
@cy83rc0llect0r cy83rc0llect0r force-pushed the pr/cy83rc0llect0r/add-nameOverride-to-helm-chart branch from 95a7785 to a0c015f Compare May 22, 2025 10:18
@cy83rc0llect0r
Copy link
Contributor Author

@mtardy Could you please check my changes?

Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

hey I don't understand your changes, are you using an LLM to generate those patches?

{{- if and .Values.tetragonOperator.enabled .Values.tetragonOperator.serviceAccount.create -}}
{{- if and .Values.tetragonOperator.serviceAccount.create }}
Copy link
Member

Choose a reason for hiding this comment

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

I don't get why you removed that?

{{- if .Values.serviceAccount.create -}}
{{- if .Values.serviceAccount.create }}
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member

Choose a reason for hiding this comment

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

sorry but what is this?

{{- define "rthooksInterface" -}}
{{ $iface := .Values.rthooks.interface }}
{{- if (eq $iface "oci-hooks") -}}
oci-hooks
oci-hooks
Copy link
Member

@mtardy mtardy May 26, 2025

Choose a reason for hiding this comment

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

should we use space? why the empty line removals?

labels:
{{- include "tetragon.labels" . | nindent 4 }}
{{- include "tetragon.labels" . | nindent 4 }}
Copy link
Member

Choose a reason for hiding this comment

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

is this expected?

@cy83rc0llect0r
Copy link
Contributor Author

hey I don't understand your changes, are you using an LLM to generate those patches?

No I didn't. I was working on another PR for Tetragon and I think everything was messed up. Let me clean it up.

@cy83rc0llect0r
Copy link
Contributor Author

@mtardy

To be honest, I felt quite disheartened and lost some focus after seeing the assumption that I might have used an LLM to patch my code. I understand that the code might appear a bit messy or unexpected, but this is primarily due to the long time gap between opening this PR and today, which has led to a lack of proper focus on this particular fork.
Given this, I prefer to either close this Pull Request or convert it to a DRAFT.

Thank you so much.

@cy83rc0llect0r cy83rc0llect0r marked this pull request as draft May 26, 2025 11:26
@mtardy
Copy link
Member

mtardy commented May 26, 2025

To be honest, I felt quite disheartened and lost some focus after seeing the assumption that I might have used an LLM to patch my code. I understand that the code might appear a bit messy or unexpected, but this is primarily due to the long time gap between opening this PR and today, which has led to a lack of proper focus on this particular fork.
Given this, I prefer to either close this Pull Request or convert it to a DRAFT.

yeah sorry it's just that it happened in the past and because I saw some random changes I thought it was that again, sorry it was indelicate! The PR is helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants