helm: `helm upgrade` does not re-create namespace when it is gone

When the namespace of a release had been deleted, upgrade fails:

Error: UPGRADE FAILED: failed to create resource: namespaces "xxxxx" not found

This is arguably a special situation, but I would expect helm to re-create the “resources that do not already exist” (https://github.com/kubernetes/helm/blob/master/pkg/kube/client.go#L201), including namespaces.

How about calling ensureNamespace there in Update, as is done in Create? I can try and send a PR for this.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 34 (15 by maintainers)

Commits related to this issue

Most upvoted comments

any updates on this?

Thank you @bacongobbler. Just for clarification, I understand if helm upgrade does not support re-creating namespaces. But, we use the --install flag along with upgrade by default helm upgrade --install and it would be nice if namespaces are also re-created in that case (when --install flag is used).

Is it recommended practice to add a namespace.yml file like so:

apiVersion: v1
kind: Namespace
metadata:
  name: {{ .Release.Namespace }}

My workaround: Add namespace: {{ .Values.namespace }} to each resource and don’t use --namespace flag

In helm list it looks like it’s deployed under default namespace though.

@technosophos Isn’t it weird that even Helm is supposed to work on global level, there are “namespaces” as first-class concept in both cli and helm list output? Wouldn’t it make more sense to drop namespace concept from helm cli at all and allow to override namespaces of all resources in some way in templates? Like:

override:
  metadata:
    namespace: {{ .Values.namespace }}