helm: Helm 3 doesn't create namespace
Output of helm version:
version.BuildInfo{Version:"v3.0.0-alpha.1", GitCommit:"b9a54967f838723fe241172a6b94d18caf8bcdca", GitTreeState:"clean"}
Output of kubectl version:
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.3", GitCommit:"721bfa751924da8d1680787490c54b9179b1fed0", GitTreeState:"clean", BuildDate:"2019-02-01T20:08:12Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.8-eks-7c34c0", GitCommit:"7c34c0d2f2d0f11f397d55a46945193a0e22d8f3", GitTreeState:"clean", BuildDate:"2019-03-01T22:49:39Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
Cloud Provider/Platform (AKS, GKE, Minikube etc.): AWS/EKS
centos7:[root@localhost linux-amd64]$ kubectl get ns nginx
Error from server (NotFound): namespaces "nginx" not found
centos7:[root@localhost linux-amd64]$ ./helm install nginx stable/nginx-ingress
Error: create: failed to create: namespaces "nginx" not found
centos7:[root@localhost linux-amd64]$ kubectl create ns nginx
namespace/nginx created
centos7:[root@localhost linux-amd64]$ ./helm install nginx stable/nginx-ingress
NAME: nginx
LAST DEPLOYED: 2019-05-17 15:30:04.283642019 +0100 BST m=+4.727707147
NAMESPACE: nginx
STATUS: deployed
NOTES:
The nginx-ingress controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace nginx get services -o wide -w nginx-nginx-ingress-controller'
An example Ingress that makes use of the controller:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: example
namespace: foo
spec:
rules:
- host: www.example.com
http:
paths:
- backend:
serviceName: exampleService
servicePort: 80
path: /
# This section is only required if TLS is to be enabled for the Ingress
tls:
- hosts:
- www.example.com
secretName: example-tls
If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:
apiVersion: v1
kind: Secret
metadata:
name: example-tls
namespace: foo
data:
tls.crt: <base64 encoded cert>
tls.key: <base64 encoded key>
type: kubernetes.io/tls
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 10
- Comments: 18 (7 by maintainers)
The change to remove the creation of the namespace during
helm installwas intentional. This was made to mimic the same behaviour askubectl create --namespace foo -f deployment.yaml- namespaces are a global cluster resource and the user installing resources into that namespace may not have the proper administrative rights to install the namespace itself, as that implies you have full administrative rights to the cluster (as opposed to being bound to a role with restricted rights within a particular namespace). Without this change, users must have cluster admin rights to install a chart, and we want to ensure that administrators can ensure users only have a restricted set of roles applied to each install. This is also a big reason why TIller was removed in the first place.Additionally, there have been several asks in the community to allow modifying the namespace
helm installcreates (e.g. #3503), and the UX to support use cases like that would be incredibly painful to achieve. Offloading the namespace creation to a separate tool (perhaps a plugin?) provides users a way to solve these issues without imposing a restrictive user experience around these use cases.Note: I’m just relaying the information I know about this subject and why it was removed. I suggest asking @adamreese more about the justification for the removal.
Digging more into this. I was hoping that I could simply add a
namespace.yamldefinition into my chart as follow:Ideally nothing should prevent the
namespacecration w/ all the “bells and whistles” that comminutiy members were proposing, as long as it is created in the previously documented orderHowever, as I suspected, the reason why the “target” or
{{ .Release.Namespace }}must exist before invokinginstall(and I suspectupdate) command is directly tied to theHelm3storage implementation, which “relies” on the “target” namespace to store release information. https://github.com/helm/helm/blob/master/pkg/action/install.go#L254In very high-level understanding Helm3 performers following steps in the following order:
run in to the same issue… but resolved by switching context as mentioned in #5628 at this point i believe its just confusing to have --namespace an option.
@jeremy-donson - I 100% agree with you thats the best practice. but the error message is confusing, as you can see blow. Since its not suppose to work, these message is pointing you the wrong direction. “You must pass ‘–namespace=kube-system’ to perform this operation.”
@javajon The “Cleanup” topic is relevant, yet I think it is of a wider scope specifically when it involves “cluster-level” components. Two points:
@bacongobbler, yes, you did. Unfortunately, for me, those did not fully make sense.
After getting to the bottom of this, I guess the explanation that would make more sense (for me) would be the one you gave earlier (multiple times) plus, “oh, yeah… we are using “target” or
{{ .Release.Namespace }}namespace inHelm3for other reasons as well, like saving release information. Thus, it is problematic maintaining namespace creation via--namepaceflag” or something like that.Either way, thank you for your help.
I explained the issue and the motivation for the removal of this feature several times in previous comments. Please read my previous comments more carefully.
@ichekrygin, it is incredibly frustrating having to repeat the same statement over and over. I will repeat myself one more time.
I mentioned several times in that thread that the discussion is different than the one originally raised by the OP. The discussion in the first comment talks about the
--namespaceflag being ignored in earlier versions of Helm 3. Resources were being deployed in the default namespace regardless of what you provided to--namespace.Here’s an excerpt from the first comment:
The only similarity with these two tickets is that they both are related to the
--namespaceflag.That’s it.
Hope that clears things up.
As I mentioned earlier:
Do you have an alternative solution that does not fall to the same design flaws as indicated earlier?
Interesting #5628 pre-dates this issue and more importantly is dedicated to the same topic: However, it seems @bacongobbler thinks otherwise 😃
That’s great feedback, thank you @sudermanjr.
Yeah, we’re tracking that discussion in #5628 😃
I can verify this bug from the v3 master code, and using the scaffold chart as follows: