Skip to content

Proposal: RBAC best-practices changes #3320

Closed

Description

@omkensey

(Ref: RBAC comments in cert-manager/cert-manager#229, Helm issue #3098)

In discussion of a Jetstack PR, I have come to believe we need to at least update the best practices doc for RBAC in charts, and possibly refactor those practices.

The bit that needs updating is the current assertion that "serviceAccountName is effectively a required value". It should be optional, but generated to a unique name if not specified.

However, additional cases not handled by the current practice are:

  • a service account already exists, and a new release should create RBAC or other resources that use it
  • a service account should be created for an RBAC-enabled chart even when RBAC is not being used

In the Jetstack PR discussion, it was proposed that service account values should be split out from RBAC (since they are used by RBAC but exist independently of it) and created or not independently, e.g.:

rbac:
  create: true

serviceAccount:
  create: false
  serviceAccountName: "foo"

This adds a bit of complexity, but resolves the issue described above, and additionally allows charts to specify and use multiple service accounts if we add a layer under serviceAccount like so:

serviceAccounts:
  client:
    serviceAccountName: client-account
    create: false
  server:
    serviceAccountName: server-account
    create: true

My personal feeling is that the additional functionality, especially of the second form, is worth the small added complexity.

Activity

  1. technosophos commented on Jan 8, 2018

    @technosophos
    Member

    I agree with this. I think we should actually alter the Tiller installer to do this. I don't think this introduces any compatibility breakers. And we do this same thing with Brigade (add svc account by default, even if no RBAC), which seems to work for all users.

  2. added this to the Upcoming - Minor milestone on Jan 8, 2018
  3. added
    help wanted
    on Jan 8, 2018
  4. unguiculus commented on Jan 11, 2018

    @unguiculus
    Member

    @omkensey I thought it through again and think the proposal makes sense. I updated the PR accordingly. Please have a look at this commit: cert-manager/cert-manager@52f2c90

  5. unguiculus commented on Jan 11, 2018

    @unguiculus
    Member

    I went for a slightly shorter version:

    rbac:
      create: true
    
    serviceAccount:
      create: false
      name: "foo"
  6. whereisaaron commented on Jan 11, 2018

    @whereisaaron
    Contributor

    Our discussion on cert-manager/cert-manager#229 has disappeared, but after some discussion there, I realized that conflating Service Accounts with RBAC was complicating the use cases. I'm strongly in favor of separating the two as in @unguiculus's and @omkensey's examples above.

  7. omkensey commented on Jan 11, 2018

    @omkensey
    Author

    Per @unguiculus's example above, I think that's a good default for this (since probably a solid majority of charts that need service accounts only need one), and then we can have a standardized more-complex form (like mine :) ) for cases where one service account just won't do. We don't want to open the floodgates but I think a pattern of "best practice for simple cases" and a more complex "best practice for other cases" would serve us well for this and some other uses.

  8. unguiculus commented on Jan 11, 2018

    @unguiculus
    Member

    @whereisaaron The discussion is still there. Github just hides it as outdated.

  9. depohmel commented on Feb 22, 2018

    @depohmel

    Guys, I looked thru all discussions which were mentions here, but I didn't find why serviceAccount is on the root level of values and not under RBAC? Even that most of the clusters have RBAC enabled by default. But sometimes people are setting RBAC off cluster for testing purpose. And in those environments, SA creation might fail. So it looks like for rbac.enable=false, chart should not even try to create SA.

  10. whereisaaron commented on Feb 22, 2018

    @whereisaaron
    Contributor

    Hi @depohmel. Service Account creation won't fail even if you don't have or use RBAC. Service Accounts know nothing of RBAC, and don't care whether you have it or not 😄

    This is because Service Accounts are not part of RBAC. They are a separate function that exists independent of RBAC. RBAC is something you optionally add on top, to tell the k8s API to limit access to the API for certain Service Accounts.

    You still need Service Accounts, even you don't use RBAC (or you use ABAC or some future RBACv2 instead).

  11. depohmel commented on Feb 22, 2018

    @depohmel

    Oohhhh. Thanks. This was a missing part. Now it does make sense.

  12. unguiculus commented on Feb 23, 2018

    @unguiculus
    Member

    Fixed in #3408.

  13. unguiculus commented on Feb 23, 2018

    @unguiculus
    Member

    /close

  14. whereisaaron commented on Feb 23, 2018

    @whereisaaron
    Contributor

    good stuff!

    ...aaron boodles off to update all his old charts... 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featurehelp wanted

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions