-
Notifications
You must be signed in to change notification settings - Fork 66
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
feat: introduce namespaceOverride #126
base: main
Are you sure you want to change the base?
feat: introduce namespaceOverride #126
Conversation
Extended the Helm chart to allow for a namespace override via the new `namespaceOverride` value. This ensures that a custom namespace can be specified and used, otherwise defaults to the release namespace. This update enhances deployment flexibility in different Kubernetes environments.
Hi @khaledCNTXT! helm install localstack localstack/localstack -n this-is-my-custom-namespace --create-namespace |
Hi @alexrashed |
Interesting. Helm would use the same namespace for dependencies as well, so why wouldn't LocalStack as a dependency of the chart you mentioned not be installed in the same? Maybe the chart you mean has some special namespace handling? |
We have a Helm chart with multiple dependencies as follows:
Key Points:
|
Interesting, thanks a lot for the explanation. I can see that this can be useful, and it seems to be a somewhat-best-practice used in multiple charts. In fact, there's a utility function in I would suggest to modify your PR such that:
What do you think? |
sure i will update the PR |
I reviewed the documentation at |
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 reviewed the documentation at
https://github.com/novuhq/community-k8s/tree/fb860df320ee6b47cc109355aa1e117b16cc5d1b/helm
and it appears that common.names.namespace is not a valid option for us to use. Is there something I might be missing
I am not sure what you mean by that to be honest. We - same as the novu
chart - both have the bitnami commons chart in our dependencies. Novu already uses the common.names.namespace
in their chart (as linked above). We could do the exact same thing (see the suggested change in the comment).
Does that answer your question?
@@ -2,7 +2,7 @@ apiVersion: apps/v1 | |||
kind: Deployment | |||
metadata: | |||
name: {{ include "localstack.fullname" . }} | |||
namespace: {{ .Release.Namespace | quote }} | |||
namespace: {{ include "localstack.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.
namespace: {{ include "localstack.namespace" . }} | |
namespace: {{ include "common.names.namespace" . | quote }} |
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 was working on implementing this change when I noticed that the project uses localstack.name, localstack.fullname, and localstack.chart. We have two options: either we move everything under common.names.xxxx for consistency, or we maintain the current standard and continue using localstack.xxx. What do you think? For reference, other libraries like common have a separate file for names, such as _names.tpl.
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 trying to consolidate everything by using the common
chart utils functions is out of scope for this PR.
I also don't see a reason to create an unnecessary layer of indirection by creating a new localstack.namespace
if it is just going to use common.names.namespace
.
So in my opinion, we should just use common.names.namespace
everywhere (which is a backwards compatible change), no other changes necessary.
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've just pushed a change. Please review it and let me know if it meets the expected requirements
Updated various Kubernetes resource templates to use the 'common.names.namespace' helper instead of '.Release.Namespace'. This change standardizes the namespace declaration across all templates for consistency and maintainability.
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.
There's a bit of a misunderstanding. I tried to explain that in the comments, but imho you should be able to just remove the two sections I commented on, and it should work just fine with the value you initially proposed (namespaceOverride
).
Would you mind giving this a try? Do you have any questions on that? :)
charts/localstack/values.yaml
Outdated
common: | ||
names: | ||
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.
If we can use common.names.namespaces from the subchart, this isn't necessary:
common: | |
names: | |
namespaces: "" |
{{/* | ||
Create a default namespace for the app. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If a common.names.namespace is provided, it will be used as the namespace. | ||
*/}} | ||
{{- define "common.names.namespace" -}} | ||
{{- if .Values.common.names.namespaces }} | ||
{{- .Values.common.names.namespaces | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- .Release.Namespace | quote }} | ||
{{- end }} | ||
{{- end }} | ||
|
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 there's a bit of a misunderstanding. My point in the previous comments is that we can just directly use common.names.namespace
(exactly the same way as the Novu chart) because this is defined in the bitnami commons (which we also have as a dependency) here: https://github.com/bitnami/charts/blob/8ecfbadb2b93576772fd134aeedcb13ad20221d2/bitnami/common/templates/_names.tpl#L59-L64
So you can just remove this section, just use the (already by the subchart defined) common.names.namespaces
everywhere (as you are already 🥳), and use the value namespaceOverride
in the values
.
{{/* | |
Create a default namespace for the app. | |
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | |
If a common.names.namespace is provided, it will be used as the namespace. | |
*/}} | |
{{- define "common.names.namespace" -}} | |
{{- if .Values.common.names.namespaces }} | |
{{- .Values.common.names.namespaces | trunc 63 | trimSuffix "-" }} | |
{{- else }} | |
{{- .Release.Namespace | quote }} | |
{{- end }} | |
{{- end }} |
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 we haven't defined our own 'common', Novu will not permit us to update it. Please try downloading the Novu repository and give it a try
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.
What do you mean with "Novu will not permit us to update it"? Can't you just set arbitrary values for transitive charts? Wouldn't it just be novu.localstack.namespaceOverride
?
Motivation
Extended the Helm chart to allow for a namespace override via the new
namespaceOverride
value. This ensures that a custom namespace can be specified and used, otherwise defaults to the release namespace. This update enhances deployment flexibility in different Kubernetes environments.Changes
add namespaceOverride to Values