You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there any docs on using helm in a k8s cluster with RBAC enabled? For example, I have a pod in a cluster that wants to helm install a chart into the same cluster. In general this seems to work fine, but if RBAC is enabled, you can run into issues. Any docs on what (cluster)roles might be needed in this situation would be very helpful.
That doesn't quite cover this use case. In this use case, there' a pod in MyNamespace that has roles that limit him to only being able to really act within the MyNamespace namespace. When he tries to helm install ... using the in-cluster config, it errors out initially on the fact that the service account being used doesn't have access to list pods in kube-system.
The serviceaccount being used in the MyNamespace pod probably needs some level of access to the namespace that tiller is in (kube-system), I just don't know the extent of what roles are needed.
$ for i in role*.yaml; do kubectl create -f $i; done
role "tiller-manager" created
role "tiller-manager" created
rolebinding "tiller-binding" created
rolebinding "tiller-binding" created
Et voilà, your tiller instance in kube-system can manage resources in my-namespace after you run helm init --service-account tiller.
$ helm install stable/nginx-ingress --namespace foo
Error: release listless-whale failed: User "system:serviceaccount:kube-system:tiller" cannot get namespaces in the namespace "foo". (get namespaces foo)
$ helm install stable/nginx-ingress --namespace my-namespace
NAME: gaudy-gopher
LAST DEPLOYED: Fri Sep 22 11:20:55 2017
NAMESPACE: my-namespace
STATUS: DEPLOYED
...
This is GREAT information, but it doesn't cover what's needed to have helm actually talk to tiller if helm is running in a pod in the same cluster, but in a different namespace. When doing so, I get:
User \"system:serviceaccount:myOtherNamspace:myOtherServiceAccount\" cannot list pods in the namespace \"kube-system\".
Sorry... That wasn't very clear to me from the previous comments. I thought you were just asking about how to run tiller in an RBAC-enabled cluster as a lot of users get confused with helm/tiller. Sorry about that!
If you're communicating with tiller via helm internal to the cluster, I think you just need to grant the pod running helm the role to list pods in the namespace tiller's running from, as the error suggests. To do that, assuming your helm pod is in namespace foo:
You could narrow the "apiGroups" set on the "pod-lister" Role above.
Also, in the "tiller-manager" Role above, I don't think Tiller needs access to the "secrets" resource within its containing namespace—unless you're using the new secret-based release backend, right?
Actually I'm going to re-open this as an action item to put this in the documentation. I've referenced it on several occasions, so it's probably best to get this enshrined in the docs.
Activity
bacongobbler commentedon Sep 22, 2017
https://github.com/kubernetes/helm/blob/master/docs/service_accounts.md explains how to set up the service accounts for tiller based on your requirements. I couldn't find the link in the official documentation though.
alapidas commentedon Sep 22, 2017
That doesn't quite cover this use case. In this use case, there' a pod in
MyNamespacethat has roles that limit him to only being able to really act within theMyNamespacenamespace. When he tries tohelm install ...using the in-cluster config, it errors out initially on the fact that the service account being used doesn't have access to list pods inkube-system.The serviceaccount being used in the
MyNamespacepod probably needs some level of access to the namespace that tiller is in (kube-system), I just don't know the extent of what roles are needed.bacongobbler commentedon Sep 22, 2017
Isn't that explained in https://github.com/kubernetes/helm/blob/master/docs/service_accounts.md#example-service-account-restricted-to-a-namespace? It goes through the documentation on how to create a
tillerservice account along with the proper roles and role bindings to grant tiller the ability to create resources in that namespace. If you have a tiller instance inkube-systemand you want to grant it access to install resources inmy-namespace, just tweak the documentation to suit your needs.First, create the namespace and a tiller service account in the
kube-systemnamespace:Then, define a role called
role-tiller.yamlthat allows one to manage resources inmy-namespace:Then bind that role to the tiller service account in
kube-system. Inrolebinding-tiller.yaml:You'll also need to grant tiller access to read configmaps in kube-system so it can store release information. In
role-tiller-kube-system.yaml:And then the respective role binding (
rolebinding-tiller-kube-system.yaml):And finally, piecing it all together:
Et voilà, your tiller instance in kube-system can manage resources in
my-namespaceafter you runhelm init --service-account tiller.alapidas commentedon Sep 22, 2017
This is GREAT information, but it doesn't cover what's needed to have helm actually talk to tiller if helm is running in a pod in the same cluster, but in a different namespace. When doing so, I get:
bacongobbler commentedon Sep 22, 2017
Sorry... That wasn't very clear to me from the previous comments. I thought you were just asking about how to run tiller in an RBAC-enabled cluster as a lot of users get confused with helm/tiller. Sorry about that!
If you're communicating with tiller via helm internal to the cluster, I think you just need to grant the pod running helm the role to list pods in the namespace tiller's running from, as the error suggests. To do that, assuming your helm pod is in namespace
foo:role-podlister.yaml
rolebinding-podlister.yaml
I think that's about as exhaustive of a list of docs I can come up with. Let me know if something doesn't work.
seh commentedon Sep 28, 2017
You could narrow the "apiGroups" set on the "pod-lister" Role above.
Also, in the "tiller-manager" Role above, I don't think Tiller needs access to the "secrets" resource within its containing namespace—unless you're using the new secret-based release backend, right?
bacongobbler commentedon Oct 19, 2017
@seh correct. I had #2721 in mind when writing this example. :)
If you're using the default configmap storage backend then you can omit
secretsfrom thetiller-managerrole.bacongobbler commentedon Oct 19, 2017
@alapidas does that help answer your question, or is there something else you'd like to know?
alapidas commentedon Oct 19, 2017
That probably does it - I haven't had a chance to test this, but let's close this out for now. Thanks!
bacongobbler commentedon Oct 30, 2017
Actually I'm going to re-open this as an action item to put this in the documentation. I've referenced it on several occasions, so it's probably best to get this enshrined in the docs.