Skip to content

Chart doesn't respect namespace when used with Kustomize HelmCharts in Argo CD app of apps pattern #96

@gabrielcosi

Description

@gabrielcosi

Description

When deploying the Windmill Helm chart using Kustomize's HelmCharts feature within an Argo CD app of apps pattern, all resources are being created in the ArgoCD namespace instead of the intended namespace specified in the Kustomization file.

Current Setup and Behavior

I have an app of apps setup with ApplicationSet and AppProject:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: tools
  namespace: argocd
spec:
  generators:
    - git:
        repoURL: https://github.com/gabrielcosi/homelab
        revision: HEAD
        directories:
          - path: kubernetes/apps/tools/*
  template:
    metadata:
      name: "{{ path.basename }}"
    spec:
      project: tools
      source:
        plugin:
          name: kustomize-build-with-helm
      destination:
        name: in-cluster
        namespace: argocd  # This seems to override the namespace specified in Kustomization

Inside one of the tool directories, I have a Kustomization using HelmCharts:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ns.yaml
  - cnpg-db.yaml
  - http-route.yaml
  - db-credentials.yaml
helmCharts:
  - name: windmill
    repo: https://windmill-labs.github.io/windmill-helm-charts/
    version: 2.0.384
    releaseName: windmill
    namespace: windmill
    valuesFile: values.yaml

The issue appears to be a combination of:

  1. The ApplicationSet template specifying namespace: argocd
  2. The Helm chart templates not explicitly handling namespace inheritance
  3. Kustomize's HelmCharts namespace specification not being respected in this setup

Expected Behavior

Resources should be deployed to the namespace specified in the Kustomization file's HelmCharts section (windmill in this case), regardless of the ApplicationSet's destination namespace.

Suggested Fix

Add namespace templating to the Helm chart templates, for example:

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

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