Search code examples
kuberneteskubernetes-helmrbac

Helm RBAC rules to create namespaces and resources inside those created name


I found a lot of information on how to give helm permission to create resources in a particular namespace.

I am trying to see if I can create namespaces on the fly(with random names) and then use helm to install and delete resources inside the namespace.

My idea is to create a namespace with name such as Fixedsuffix-randomprefix and then allow helm to create all resources inside it. Is this possible ?

I can create a clusterrole and clusterrolebinding to allow tiller's serviceaccount to create namespaces, but I am not able to figure out how to have a serviceaccount that could create resources in the particular namespace( mainly because this serviceaccount to create resources cant would have to be created when the namespace is created and then assigned to tiller pod).

TIA


Solution

  • My question is why would you create sa, clusterrole and rolebinding to do that? Helm has it´s own resources which allow him to install and delete resources inside new namespace.

    My idea is to create a namespace with name such as Fixedsuffix-randomprefix and then allow helm to create all resources inside it. Is this possible ?

    Yes, you can create your new namespace and use helm to install everything in this namespace.Or even better you can just use helm install and it will create new namespace for you. For that purpose helm have helm install --namespace.

    -n, --namespace string namespace scope for this request

    For example you can install traefik chart in namespace tla.

    helm install stable/traefik --namespace=tla
    NAME:   oily-beetle
    LAST DEPLOYED: Tue Mar 24 07:33:03 2020
    NAMESPACE: tla
    STATUS: DEPLOYED
    

    Another idea which came to my mind is you might want tiller not to use cluster-admin credentials, then this link could help.