traefik-helm-chart icon indicating copy to clipboard operation
traefik-helm-chart copied to clipboard

Defining namespace in the command "helm template" doesn't add namespace to metadata

Open fheinonen opened this issue 5 years ago • 5 comments
trafficstars

Defining namespace in the command in helm template doesn't add namespace metadata in the generated files. I'm using helm version 3.2.4. Here's the commands I ran:

helm fetch traefik/traefik --version 9.1.0
helm template traefik-9.1.0.tgz --output-dir . -f ~/kubernetes-charts/traefik.yml --name-template traefik --namespace traefik --include-crds

Here's a snippet of the deployment.yaml and no namespace is added to the metadata of the generated file:

---
# Source: traefik/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: traefik
  labels:
    app.kubernetes.io/name: traefik
    helm.sh/chart: traefik-9.1.0
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/instance: traefik
  annotations:
spec:

fheinonen avatar Aug 26 '20 13:08 fheinonen

helm template does not add namespaces. v3 never has.

dirtycajunrice avatar Sep 27 '20 17:09 dirtycajunrice

But then shouldn't the Service and Deployment be templated for the namespace, like other resources are?

memelet avatar Nov 24 '20 04:11 memelet

Is the expectation then to just always install traefik to the default namespace?

abatilo avatar Feb 03 '21 01:02 abatilo

I am facing a similar issue. I'm quite sure this is on my side but I can't get my head around it. I deployed the chart with helm specifying the namespace (--namespace). Everything gets deployed correctly into this namespaces, except the service. The service is deployed into the default namespace. Did anyone else face a similar issue and figured out why?

muhlba91 avatar Aug 23 '21 21:08 muhlba91

I am facing a similar issue. I'm quite sure this is on my side but I can't get my head around it. I deployed the chart with helm specifying the namespace (--namespace). Everything gets deployed correctly into this namespaces, except the service. The service is deployed into the default namespace. Did anyone else face a similar issue and figured out why?

This is not a chart issue as the chart does not specify a namespace (as it shouldn't), but in the spirit of helpfulness: If you are using CLI, the safest way to install a helm chart is not to use --namespace but to change current namespace to the desired namespace in question and then helm install. Many automation systems do most of this work for you, but manually this is a battle-tested assurance. (kubectl config set-context --current --namespace=<yournamespacehere).

dirtycajunrice avatar Aug 26 '21 19:08 dirtycajunrice

With current version of Helm and this Chart, all objects are deployed in the target namespace, Service included.

mloiseleur avatar Oct 17 '22 09:10 mloiseleur