Welcome to the Linux Foundation Forum!

LFS158: RBAC Authorization RoleBinding vs ClusterRoleBinding

LikaB
LikaB Posts: 4

For RoleBinding, the example shared includes:

subjects:
- kind: User
  name: bob
  apiGroup: rbac.authorization.k8s.io

For ClusterRoleBinding, the example shared includes:

subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: Group
  name: system:admins

Since the subject is an ordered list, order should matter? But the order is different for RoleBinding, and ClusterRoleBinding - I wonder if the ClusterRoleBinding example would work?
(https://kubernetes.io/docs/reference/access-authn-authz/rbac/ shows it as having the same order as RoleBinding)
Something to try, I guess!

Answers

  • LikaB
    LikaB Posts: 4

    Edited to better represent code

  • Flavia
    Flavia Posts: 2,651

    Hi @LikaB

    Please use the code block in the post ribbon. It will preserve the proper formatting and should not trigger any reviews.

    Best,
    Flavia

  • chrispokorni
    chrispokorni Posts: 2,620

    Hi @LikaB,

    Within the same indent block order does not matter. You can write the attribute pairs in alphabetical order, or order them based on personal preference.

    Regards,
    -Chris

  • LikaB
    LikaB Posts: 4

    @Flavia Thx for the explanation... but that's what I used in the final edit? a code block. Must've done something wrong ...

    @chrispokorni Thanks, that's true of YAML maps, sure, but the hyphen indicates an ordered list, does it not?

  • chrispokorni
    chrispokorni Posts: 2,620

    Hi @LikaB,

    Yes, the hyphen is used to identify an element (or the beginning of an element) of the ordered list. While the alphabetical ordering is not essential within the element itself, the list items can still be ordered based on preference.

    Regards,
    Chris

Categories

Upcoming Training