-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Kustomize doesn't pass namespace to helmCharts, resulting in inconsistent output #5566
Comments
@Skaronator
So please consider using the
/triage out-of-scope |
Hi @koba1t, thanks for taking your time. The current implementation causes inconsistent YAML files. Defining the namespace within helmCharts is often not possible. For example, when ArgoCD dynamically sets the namespace in kustomize. I'd expect if |
This really seems closer to a bug @koba1t. Setting the namespace at the kustomize level inflates the helm chart, rewrites all the objects to the namespace, but then misses things like connection strings, thus deploying the chart in a broken state. Example, the airflow helm chart here: You can see it relies on {{ .Release.Namespace }} as part of the default connection to its database, thus if you don't match the namespaces between kustomize and the helmChart, then you have something that looks functional but isn't. |
I too agree that this looks to be a bug on Kustomize side. I believe the correct strategy would be if a namespace is define in
kustomize should not transform the namespace, but instead let This would ensure that any built-in variable such as
This looks to be partially related to #4593 |
Hi, I found a workaround solution, to at least not repeat yourself in the patch resources. Instead of adding the Ref apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: amp-airflow-prod
helmCharts:
- name: airflow
repo: https://charts.bitnami.com/bitnami
releaseName: amp-airflow
namespace: amp-airflow-prod
version: 17.2.4
valuesFile: values.yml
resources:
- secrets.yml
patches:
- path: amp-airflow-exporter-patch.yml
target:
kind: Deployment
name: amp-airflow-exporter
# namespace: amp-airflow-prod The patch: apiVersion: apps/v1
kind: Deployment
metadata:
name: amp-airflow-exporter
# namespace: amp-airflow-prod
spec:
template:
spec:
containers:
- name: airflow-exporter
env:
- name: TEST
value: "test" The patch was applied to the right resource, and the env var is there :) |
I have the exact same behavior with this namespace... ... when deploying it as kustomization with argocd. |
I get this problem when deploying vernemq helm chart with kustomize through argocd. All of its resources except a service account, a role, and a rolebinding end up in the right place. |
The desire isn't for kustomize to do anything with
Means any overlay like:
Will still result in the use of |
Given the numerous comments and the 13 thumbs up on my original issue, could you please reconsider if it's still out-of-scope and update the labels accordingly? Thanks |
On slack someone explained why kustomize can't pass the I also know @koba1t is working on new helm support #4401 (comment) and curious if it'll be done there. |
Hmm.. I am worried that this feature may have a huge change due to this function, which means any transformer output affects another transformer... /kind feature |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
selfish bump |
Just ran headlong into this. Because of the use of the helm binary and it not passing the namespace through. It picked up the namespace defined in my kube config file as the So as an example, using the following namespace: cert-manager
helmCharts:
- name: cert-manager
repo: https://charts.jetstack.io You can use ❯ kustomize build --enable-helm | yq ea 'select(.kind == "ValidatingWebhookConfiguration").metadata.annotations'
cert-manager.io/inject-ca-from-secret: something-else/cert-manager-webhook-ca koba1t As a quick patch to stop the unexpected behaviour, would it be possible to just adding the |
I think we already have a |
What happened?
When using Kustomize with Helm charts, the namespace defined at the top level in the kustomization.yaml file is not correctly propagated to the helmCharts releases. As a result, the generated YAML files contains inconsistent values.
kustomization.yaml
Helm Chart Template
Result
This inconsistency can cause issues when deploying resources, such as Bitnami Minio Chart, which relies on the {{ .Release.Namespace }} to dynamically create the service URL.
https://github.com/bitnami/charts/blob/e8999fedbd8e35c96099aa44d3ca4ea947bfbe22/bitnami/minio/templates/distributed/statefulset.yaml#L150
What did you expect to happen?
I expected that the namespace defined in the top level of the kustomization.yaml file would be passed down to all helmCharts releases.
When a Helm chart entry already specifies a namespace, that namespace should take precedence.
How can we reproduce it (as minimally and precisely as possible)?
Repository to reproduce it is available here: https://github.com/Skaronator/kustomize-namespace-bug
Expected output
Actual output
Kustomize version
v5.3.0
Operating system
Linux
The text was updated successfully, but these errors were encountered: