Skip to content

Support explicit namespace rendering for Kustomize v5.8+ compatibility #79

Description

@Xanonymous-GitHub

I noticed the related PR #68, so apologies if this should be handled there instead. I wanted to ask whether you would be open to adding explicit namespace support to the chart, possibly as an opt-in namespaceOverride value.

Context

The reason this came up for us is Kustomize v5.8.0+.

In kubernetes-sigs/kustomize#5940, Kustomize changed Helm namespace handling so Helm-generated resources are expected to manage their own namespaces. The v5.8.0 release notes mention this under:

fix: Propagate Namespace correctly to Helm

The PR summary also notes:

If you use Kustomize with Helm charts, ensure that your Helm templates explicitly set the namespace, for example:

metadata.namespace: {{ .Release.Namespace }}

There are also Kustomize issues from users seeing this after upgrading:

Issue kubernetes-sigs/kustomize#6058 is open/accepted and describes the case where Kustomize 5.8.0 no longer adds namespaces to Helm chart resources that do not set an explicit namespace.

Current behavior

When this chart is rendered through Kustomize helmCharts, users may configure a namespace like this:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: chartmuseum

helmCharts:
  - name: chartmuseum
    repo: https://chartmuseum.github.io/charts
    releaseName: chartmuseum
    namespace: chartmuseum

With Kustomize v5.8.0+, chart resources that do not render metadata.namespace may no longer get the namespace injected by Kustomize. This can leave users needing extra Kustomize patches to add namespaces to resources such as Service, Deployment, Secret, PersistentVolumeClaim, Ingress, and ServiceAccount.

Those patches are somewhat fragile because the list can change when chart templates change.

Relationship to #68

PR #68 already proposed adding explicit namespace rendering to several templates using:

namespace: {{ .Release.Namespace }}

This request is related, but slightly different.

Instead of unconditional namespace rendering, would you prefer an opt-in approach that keeps the chart's default output mostly unchanged?

For example:

  • Add namespaceOverride: ""
  • Add a helper resolving to .Values.namespaceOverride or .Release.Namespace
  • Add metadata.namespace only when namespaceOverride is set
  • Keep cluster-scoped resources such as PersistentVolume namespace-free
  • Use the same helper for ServiceMonitor.namespaceSelector.matchNames

I have a small branch prepared here if helpful:

https://github.com/Xanonymous-GitHub/chartmuseum-charts/tree/feat/add-chartmuseum-namespace-override

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions