Skip to content

Kustomize 5.8.0 no longer add namespaces to resources in helm charts without explicit namespace #6058

@codestation

Description

@codestation

What happened?

Before kustomize 5.8.0 if i declare the namespace in the /namespace of the kustomization.yaml file it will add a namespace to all the resources without an explicit namespace.

After 5.8.0 it won't add the namespace, breaking several 3rd party charts where the resources doesn't have an explicit namespace: {{ .Release.Namespace }} template.

For example i can no longer install the mariadb-operator chart in argocd after the kustomize update because the resources no longer have a namespace.

As a workaround for this specific chart i am using the following:

patches:
  - target:
      kind: (ConfigMap|ServiceAccount|Deployment|ServiceMonitor|Role|RoleBinding|Service)
    patch: |-
      - op: add
        path: /metadata/namespace
        value: mariadb-system

But this can break anytime the chart or values.yaml is updated.

What did you expect to happen?

The resources must have a namespace like in previous versions.

How can we reproduce it (as minimally and precisely as possible)?

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: mariadb-system
helmCharts:
  - name: mariadb-operator
    repo: https://helm.mariadb.com/mariadb-operator
    version: 25.10.4
    releaseName: mariadb-operator
    namespace: mariadb-system

Expected output

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/instance: mariadb-operator
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: mariadb-operator
    app.kubernetes.io/version: 25.10.4
    helm.sh/chart: mariadb-operator-25.10.4
  name: mariadb-operator
  namespace: mariadb-system
spec:
...

Actual output

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/instance: mariadb-operator
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: mariadb-operator
    app.kubernetes.io/version: 25.10.4
    helm.sh/chart: mariadb-operator-25.10.4
  name: mariadb-operator
spec:
...

Kustomize version

5.8.0

Operating system

Linux

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions